Posts

Showing posts from July, 2013

How to Avoid recursive trigger in salesforce ?

Avoiding recursive triggers in Salesforce is crucial to prevent infinite loops and excessive consumption of system resources. Here are several strategies to achieve this: Use a Static Variable or Flag : Utilize a static Boolean variable or a static set to keep track of whether the trigger logic has already been executed. This prevents the trigger from re-executing when it's not necessary. public class TriggerHandler {     private static Boolean isFirstRun = true;     public static void onBeforeInsert(List<MyObject__c> newList) {         if (isFirstRun) {             // Trigger logic             isFirstRun = false;         }     } } Use a Handler Class : Implement a separate handler class to encapsulate trigger logic. This class can have static variables to manage recursion and can be called from the trigger. public class TriggerHandler {     p...

Use of render, rerender, and renderAs in Salesforce

In Salesforce, render, rerender, and renderAs are terms used in the context of Visualforce pages and components. Each term relates to a different aspect of how Visualforce content is displayed or processed. render determines whether a component should be displayed on the page based on a condition. rerender specifies which components should be updated with new data after an AJAX action. renderAs defines the format in which the Visualforce page should be rendered, such as PDF, Excel, or CSV. render : Usage : Used in Visualforce components and tags to define the conditions under which the component or tag should be rendered on the page. Description : The render attribute specifies a Boolean value or expression that determines whether the associated component or tag should be rendered (displayed) on the page. If the value evaluates to true, the component is rendered; otherwise, it is omitted from the page's HTML output. Example : <apex:outputText value="Hello World!" re...