Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set<String> otherProgramsValueSet = new Set<String>();
- for (Lead em : Trigger.new) {
- if(em.Email != null){
- listEmail.add(em.Email);
- }
- if(em.What_is_your_primary_program_of_interest__c != null ){
- listname.add(em.What_is_your_primary_program_of_interest__c);
- }
- if(em.Other_Programs__c != null){
- // this will construct a set of values selected in multiselect. Set will maintain unique values.
- // Multiselect values are semi-colon separated, hence the split function.
- otherProgramsValueSet.addAll(em.Other_Programs__c .split(';'));
- }
- }
- //Query account records with matching names.
- //Iterate over this list to create new Affiliation records
- List<hed__Affiliation__c> affiliationListToBeInserted = new
- List<hed__Affiliation__c>();
- for(Account acc : [select id from account where name in : otherProgramsValueSet]){
- affiliationListToBeInserted.add(new hed__Affiliation__c(Account__c= acc.Id));
- }
- insert affiliationListToBeInserted;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement