You need to sign in to do that
Don't have an account?
Phuc 2
Share Map between classes
Hell all,
I am trying to figure out how to share a map between my main Class and a utility Class.
Main Class
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,
P
I am trying to figure out how to share a map between my main Class and a utility Class.
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
public void updateRecord(record__c newRecord, Account newAccount){ if(newAccount != null && newRecord != null){ newAccount.isAcount = true; updateMap.put(newAccount.Id, newAccount); } return updateMap; }
What is the best option for passing the updateMap from the util class back to the main class? Any help is appreciated.
Cheers,
P
Try below code. If it solves your issue kindly mark it as best answer.