How to avoid the issue, Kindly help me pls
MY TRIGGER :
trigger AccountTrigger on Account (after insert, before update, after update, after delete) {
/* Assign & create Account team members based on user department*/
if(Trigger_Status__c.getValues('AccountTeam').Active__c && Trigger.isUpdate && Trigger.isBefore ){
/* Before insert process */
AccountTriggerHelper.updateAccountTeam(Trigger.newMap, Trigger.oldMap);
}
/* Trigger to invoke the AccountIneligibilty Logs Tracking*/
if(Trigger_Status__c.getValues('AccountEligibilityLogTrigger').Active__c && Trigger.isAfter && Trigger.isUpdate){
AccountTriggerHelper.createAccountEligiblityLogs(Trigger.newMap, Trigger.oldMap);
}
/* Trigger to invoke the DiscountCode Calculations on Products*/
if(Trigger_Status__c.getValues('AccountAirlineLeveltrigger').Active__c && Trigger.isAfter && Trigger.isUpdate) {
AccountTriggerHelper.calculateDiscountCode(Trigger.newMap,Trigger.oldMap);
}
/* Trigger to invoke the DeleteAccount Tracking of Records*/
if(Trigger_Status__c.getValues('AccountDeleteTrigger').Active__c && Trigger.isAfter && Trigger.isDelete) {
AccountTriggerHelper.createDelAccountLogTracker(Trigger.oldMap);
}
}
MY CLASS:
public class AccountTriggerHelper {
/*--------------------------------------------------------------------------------------
Method Name: updateAccountTeam
Description: Method to Assign & create Account team members based on user department
Parameter: Account New Map & Old Map
--------------------------------------------------------------------------------------*/
public static void updateAccountTeam(Map<Id,Account> newMapAccount, Map<Id,Account> oldMapAccount){
try{
AccountTeamHandler accHandler = new AccountTeamHandler();
List<Account> lstNewAccount = newMapAccount.values();
accHandler.setRevenueManualUpdate(lstNewAccount, oldMapAccount);
accHandler.createAccountTeamMembers(lstNewAccount, oldMapAccount);
}
catch(Exception ex){
String recType = CustomSettingsUtilities.getConfigDataMap('Log Exception Logs Rec Type');
CreateLogs.LogWrapper logWrap = new CreateLogs.LogWrapper('Account Team - Account Trigger', 'AccountTriggerHelper',
'updateAccountTeam', UserInfo.getUserName(), '',
'', false, recType);
Log__c objLogs = CreateLogs.createLogRec(logWrap, '');
CreateLogs.createApplicationLog(objLogs, ex);
}
}
/*--------------------------------------------------------------------------------------
Method Name: createAccountEligiblityLogs
Description: Method to Create AccountIneligibilty Logs and Update
Parameter: Account New Map & Old Map
--------------------------------------------------------------------------------------*/
public static void createAccountEligiblityLogs(Map<Id,Account> newMapAccount, Map<Id,Account> oldMapAccount){
try{
AccountEligibilityLogHandler.createAccountEligiblityLogs(newMapAccount, oldMapAccount);
}
catch(Exception ex){
String recType = CustomSettingsUtilities.getConfigDataMap('Log Exception Logs Rec Type');
CreateLogs.LogWrapper logWrap = new CreateLogs.LogWrapper('SME - Account Trigger', 'AccountTriggerHelper',
'createAccountEligiblityLogs', UserInfo.getUserName(), '',
'', false, recType);
Log__c objLogs = CreateLogs.createLogRec(logWrap, '');
CreateLogs.createApplicationLog(objLogs, ex);
}
}
/*--------------------------------------------------------------------------------------
Method Name: calculateDiscountCode
Description: Method to DiscountCode Calculations on Products
Parameter: Account New Map & Old Map
--------------------------------------------------------------------------------------*/
public static void calculateDiscountCode(Map<Id,Account> newMapAccount, Map<Id,Account> oldMapAccount){
try{
AccountAirlineLevelHandler.updateDiscountCodeOnProducts(newMapAccount, oldMapAccount);
}
catch(Exception ex){
String recType = CustomSettingsUtilities.getConfigDataMap('Log Exception Logs Rec Type');
CreateLogs.LogWrapper logWrap = new CreateLogs.LogWrapper('SME - Account Trigger', 'AccountTriggerHelper',
'calculateDiscountCode', UserInfo.getUserName(), '',
'', false, recType);
Log__c objLogs = CreateLogs.createLogRec(logWrap, '');
CreateLogs.createApplicationLog(objLogs, ex);
}
}
/*--------------------------------------------------------------------------------------
Method Name: createDelAccountLogTracker
Description: Method to Create Delete Tracker Logs records when any Account is Deleted
Parameter: Account Old Map
--------------------------------------------------------------------------------------*/
public static void createDelAccountLogTracker(Map<Id,Account> oldMapAccount){
try{
String recTypeName = CustomSettingsUtilities.getConfigDataMap('Del Log SME Account Rec Type');
List<CreateLogs.DeleteLogWrapper> lstDelLogWrapper = new List<CreateLogs.DeleteLogWrapper>();
for(Account acc: oldMapAccount.values()){
String directvalue = CustomSettingsUtilities.getConfigDataMap('AccListner Type Direct Stream');
if(acc.Listner_Type__c == directvalue){
CreateLogs.DeleteLogWrapper delLogWrapper = new CreateLogs.DeleteLogWrapper();
delLogWrapper.recType = recTypeName;
delLogWrapper.recName = acc.Name;
delLogWrapper.abnNumber = acc.ABN_Tax_Reference__c;
delLogWrapper.sobjectId = acc.Id;
delLogWrapper.sobjectName = 'Account';
lstDelLogWrapper.add(delLogWrapper);
}
}
List<Delete_Tracker_Log__c> lstDelTrackerLog = CreateLogs.createDeleteLog(lstDelLogWrapper);
insert lstDelTrackerLog;
}catch(Exception ex){
String recType = CustomSettingsUtilities.getConfigDataMap('Log Exception Logs Rec Type');
CreateLogs.LogWrapper logWrap = new CreateLogs.LogWrapper('Direct Stream - Account Trigger', 'AccountTriggerHelper',
'createDelAccountLogTracker', UserInfo.getUserName(), '',
'', false, recType);
Log__c objLogs = CreateLogs.createLogRec(logWrap, '');
CreateLogs.createApplicationLog(objLogs, ex);
}
}
}
Kindly help me pls
Thanks in AdvanceI don't see a lot of scope for improvement in the above code. Except that the line 78 can be moved outside the FOR loop so that it doesn't have to be called multiple times.
String directvalue = CustomSettingsUtilities.getConfigDataMap('AccListner Type Direct Stream')
This line can be added before line 77.
Unless there are other triggers on Account object that needs to be improved, you have to live with a smaller batch size.Please mark this question as solved, if this addresses your issue.