Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. Set<String> otherProgramsValueSet = new Set<String>();
  2. for (Lead em : Trigger.new) {
  3. if(em.Email != null){
  4. listEmail.add(em.Email);
  5. }
  6. if(em.What_is_your_primary_program_of_interest__c != null ){
  7. listname.add(em.What_is_your_primary_program_of_interest__c);
  8. }
  9. if(em.Other_Programs__c != null){
  10. // this will construct a set of values selected in multiselect. Set will maintain unique values.
  11. // Multiselect values are semi-colon separated, hence the split function.
  12. otherProgramsValueSet.addAll(em.Other_Programs__c .split(';'));
  13. }
  14. }
  15.  
  16. //Query account records with matching names.
  17. //Iterate over this list to create new Affiliation records
  18. List<hed__Affiliation__c> affiliationListToBeInserted = new
  19. List<hed__Affiliation__c>();
  20. for(Account acc : [select id from account where name in : otherProgramsValueSet]){
  21. affiliationListToBeInserted.add(new hed__Affiliation__c(Account__c= acc.Id));
  22. }
  23. insert affiliationListToBeInserted;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement