Main Class
global void Update( SObject oldSo, SObject newSo ){
public static Map<Id, SObject> updateMap = new Map<Id, SObject>();
record__c newRecord= ( record__c ) newSo;
newAccount = newRecord.Account
utilClass.updateRecord(newRecord, newAccount)
}
if( !updateMap.isEmpty() && Trigger.isUpdate && Trigger.isAfter ){
List<SObject> updateList = updateMap.values();
updateList.sort();
List<Database.SaveResult> results = Database.update( updateList, false);
}
Util Class
What is the best option for passing the updateMap from the util class back to the main class? Any help is appreciated.Cheers,Ppublic void updateRecord(record__c newRecord, Account newAccount){
if(newAccount != null && newRecord != null){
newAccount.isAcount = true;
updateMap.put(newAccount.Id, newAccount);
}
return updateMap;
}
Hi Phuc,Try below code. If it solves your issue kindly mark it as best answer. global void Update( SObject oldSo, SObject newSo ){
public static Map<Id, SObject> updateMap = new Map<Id, SObject>();
record__c newRecord= ( record__c ) newSo;
newAccount = newRecord.Account
updateMap = utilClass.updateRecord(newRecord, newAccount)
}
if( !updateMap.isEmpty() && Trigger.isUpdate && Trigger.isAfter ){
List<SObject> updateList = updateMap.values();
updateList.sort();
List<Database.SaveResult> results = Database.update( updateList, false);
}
=======================
Utility class
public Map<Id,Account> updateRecord(record__c newRecord, Account newAccount){
Map<Id,Account> updateMap = new Map<Id,Account>();
if(newAccount != null && newRecord != null){
newAccount.isAcount = true;
updateMap.put(newAccount.Id, newAccount);
}
return updateMap;
}