Fetch Custom Setting Value in Apex
Requirement : Disable the Apex trigger using custom setting:
Solution : Create Custom setting: SetUp>> Custom Setting >> New
Create Custom setting and create a check Box field with name On_Off__c
public class ClassName
{
public void onAfterUpdate(list<SOBJECT> triggerNew, map<id,SOBJECT> triggerNewMap, map<id,SOBJECT> triggerOldMap)
{
// Write the Custom setting if On_Off__c = true then trigger method will be excute
List<CustomSetting__C> cstriggerOnOff = CustomSetting__C.getall().values();
if(cstriggerOnOff != null && cstriggerOnOff .size()>0){
if(cstriggerOnOff [0].On_Off__c == true)
{
MethodName(triggerNew, triggerNewMap, triggerOldMap);
}
}
}
private void MethodName(list<SOBJECT> triggerNew,map<id,SOBJECT> triggerNewMap,map<id,SOBJECT> triggerOldMap)
{
// Logic
}
}
Thanks
Sumit Shukla
Comments
Post a Comment