Posts

Showing posts from January, 2019

Troubleshooting Error: Mixed DML Exception in Salesforce

What is a Mixed DML Exception? The Mixed DML Exception occurs in Salesforce when you attempt to perform DML operations on both non-setup objects (such as Account or Contact) and setup objects (like User or Group) within a single transaction. This restriction is in place because Salesforce does not allow mixing these two types of operations to maintain data integrity. Why Are You Seeing This Error? If you encounter a Mixed DML Exception, it indicates that your code is trying to modify records from both categories in one go. This often happens in scenarios where you’re creating or updating user records while also handling other standard or custom objects. How to Avoid This Error To prevent Mixed DML Exception errors in your Salesforce development, consider the following strategies: 1. Use @future Annotation Apex class code executes synchronously, meaning it processes actions in the order they are called. To perform DML operations on Salesforce sObject records asynchronously, utilize t...

Troubleshooting Error: "System.LimitException: Too many SOQL queries: 101"

What Does This Error Mean? If you've encountered the error System.LimitException: Too many SOQL queries: 101 , you're not alone. This error commonly occurs in Salesforce development and signifies that you've exceeded the governor limit for SOQL queries. In Salesforce, the limit for synchronous transactions is 100 SOQL queries , while for asynchronous transactions, the limit is 200 . It's important to note that all SOQL queries executed within triggers fired from a single call or context contribute to this limit. Therefore, if your code is running multiple queries within triggers or loops, you may quickly reach this threshold. How to Avoid This Error To prevent this error and ensure your code runs efficiently, consider the following best practices: 1. Follow Apex Code Best Practices Always adhere to the best practices for writing Apex code. This includes optimizing your queries and structuring your code effectively to manage governor limits. 2. Avoid SOQL Queries Inside ...

Best Practices for Writing Efficient Apex Code in Salesforce. Most Important Points for a Salesforce Developers 😀

When developing in Salesforce, it’s essential to follow best practices for writing efficient and effective Apex code. This not only ensures better performance but also helps you avoid common pitfalls that can lead to governor limit exceptions or deployment errors. Here are ten best practices to keep in mind: 1. Bulkify Your Code Always ensure that your code can handle multiple records simultaneously. This means using collections and avoiding single-record operations to enhance performance. 2. Avoid SOQL Queries and DML Operations Inside FOR Loops Never place SOQL queries or DML statements (such as update, insert, or delete) within a for loop. Doing so can lead to hitting governor limits quickly, as Salesforce imposes strict limits on the number of SOQL queries and DML statements that can be executed in a single transaction. 3. Bulkify Code for Helper/Utility Methods Design your helper or utility methods to handle collections of records. Use collections such as Lists, Sets, Maps, or Arr...

Metadata Types That Cannot Be Deployed or Retrieved with Metadata API in Salesforce

When working with Salesforce, understanding the limitations of the Metadata API (such as ANT and Eclipse) is crucial for effective deployment and management of your organization’s metadata. Below is a comprehensive list of metadata types that cannot be deployed or retrieved using the Metadata API and must be updated manually: Metadata Types Requiring Manual Updates Account Teams Activity Button Overrides Analytic Settings Automated Case User Settings Auto-number on Customizable Standard Fields Calendars Campaign Influences Case Contact Roles Case Feed Layouts Case Team Roles Console Layouts Multiline Layout Fields for Contract Line Items Currency Exchange Rates Data Category Visibility Settings Delegated Administration Divisions Fiscal Year File Upload and Download Security Settings Lead Settings Live Agent Chats Routed with Omni-Channel Mail Merge Templates Mobile Administration Mobile Users and Devices Multiline Layout Fields for Opportunity Teams Offline Briefcase Configurations Opp...