SHARE
TWEET

Untitled

a guest Jun 25th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. trigger ContatctoAccount on Contact (before insert, before update) {
  2.  
  3. list<Contact> Cont = new list<Contact>();
  4. Map<String,Account> mapCodeWithAccount = new Map<String,Account>();
  5. for(Account acc: [select id,Account_Code__c from Account where Account_Code__c != Null]){
  6.     if(acc.Account_Code__c!= null){
  7.         mapCodeWithAccount.put(acc.Account_Code__c, acc);
  8.     }
  9. }
  10. for(Contact C : trigger.new){
  11.     if(mapCodeWithAccount.containsKey(c.Account_Code__c)){
  12.         c.AccountID = mapCodeWithAccount.get(c.Account_Code__c).id;
  13.         Cont.add(c);
  14.     }
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top