Skip to content

Instantly share code, notes, and snippets.

@escgeek
Created January 31, 2018 20:47
Show Gist options
  • Save escgeek/24697ab778509791f95f1ec1495270ee to your computer and use it in GitHub Desktop.
Save escgeek/24697ab778509791f95f1ec1495270ee to your computer and use it in GitHub Desktop.
public static void setBUKey(List<Business_Metrics__c> newTrigger){
String buKeyList;
String buKey;
Map<String,Business_Unit__c> buMap = Business_Unit__c.getAll();
for(Business_Metrics__c bmx : newTrigger){
buKey = NULL;
if(bmx.Business_Unit__c != NULL){
buKeyList = bmx.Business_Unit__c;
List<String> buValues = buKeyList.split(';');
for(string s : buValues){
system.debug('s: ' + s);
if(buKey == NULL){
buKey = buMap.get(s).Key__c;
}
else{
buKey = buKey + ', ' + buMap.get(s).Key__c;
}
}
bmx.Business_Unit_Key__c = buKey;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment