Skip to main content

Posts

Showing posts with the label DMLException

Latest Post

Custom Metadata Types vs Custom Settings vs Custom Labels

  Custom Metadata Types vs Custom Settings vs Custom Labels 💬 In plain words:  Three lookalikes: Custom Metadata = configuration that DEPLOYS with your code (best for app settings). Custom Settings = org/user-specific values, changeable at runtime (hierarchy type is great for bypass switches). Custom Labels = translatable text for the UI. 📌 Example:  API endpoint URLs per environment → Custom Metadata (deploys with code, sandbox vs prod values). A 'Bypass_Automation__c' checkbox an admin flips during data load → hierarchy Custom Setting. The word 'Submit' translated to Hindi → Custom Label. 🎬 Real-Life Example: The Fee Table Trapped Inside Code  Skyline charges a different delivery fee per city. Apex needs those rates on every booking. The Old/Bad Way:  if (city == 'Delhi') fee = 50. Else if (city == 'Mumbai') fee = 65. … Every rate change is a code change, a test run, and a deployment. Why this is bad:  Business data is trappe...

Catching and Handling Exceptions in Salesforce Apex

Introduction : Exception handling is a critical aspect of developing robust and reliable applications in Salesforce Apex. Exceptions occur when unexpected situations or errors arise during code execution, and handling them appropriately ensures that your application continues to function smoothly. In this blog post, we will explore the concept of catching and handling exceptions in Salesforce Apex, providing you with the knowledge to handle exceptions effectively in your code. Table of Contents: 1. Introduction 2. What are Exceptions? 3. Exception Handling in Apex 4. Types of Exceptions 5. Using Try-Catch Blocks 6. Catching Specific Exceptions 7. Throwing Custom Exceptions 8. Best Practices for Exception Handling 9. Conclusion What are Exceptions? In programming, an exception is an event that occurs during the execution of a program and disrupts its normal flow. Exceptions can be caused by a variety of factors, such as invalid input, database errors, or unexpected condit...

Demystifying DML Exceptions in Salesforce Apex

Introduction : In Salesforce development, Data Manipulation Language (DML) operations are fundamental for interacting with the database. While working with DML statements in Apex, it's essential to understand the various exceptions that can occur during the execution of these operations. In this blog post, we will explore common DML exceptions in Salesforce Apex and how to handle them effectively. Table of Contents: 1. Introduction 2. What are DML Operations? 3. Common DML Exceptions    a. DMLException    b. LimitException    c. MixedDmlException    d. InsufficientPrivilegesException 4. Handling DML Exceptions    a. Try-Catch Blocks    b. Exception Methods    c. Custom Error Handling 5. Best Practices for DML Exception Handling 6. Conclusion What are DML Operations? Data Manipulation Language (DML) operations in Salesforce Apex are used to create, update, delete, and retrieve records in the Salesfor...

Popular Posts

Salesforce LWC Code for Multi-Select Lookup

Introduction: In Salesforce Lightning Web Components (LWC), implementing a multi-select lookup field can enhance the user experience and provide greater flexibility for selecting multiple related records. In this blog post, we will walk through the process of creating a multi-select lookup field using LWC. We will cover the required code snippets and provide step-by-step instructions to help you implement this functionality in your Salesforce org.