function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mike SoudeeMike Soudee 

Before trigger to copy Case custom field to Account AccountId field

Hello,

I want to populate the Account.AccountId field with a value submitted by the web-to-case form. AccountId is not available to web-to-case, so I am trying to implement the solution proposed here: https://developer.salesforce.com/forums/?id=906F0000000g09HIAQ

What does a trigger to copy Case.customField into Account.accountId look like?
Rounak SharmaRounak Sharma
hi mike,

Please refer the trigger format and let me know if you are facing any dificulty with it
rounak kumar sharma 2:55 PM
for(case cas:trigger.new) {   account acc=[select id, ownerid from account where id=:cas.accountid ];    
   If(cas.origin =='EmailToCase') {
       case cs = new case();
       cs.id = cas.id;
       cs.ownerId = acc.ownerId;
       caselist.add(cs);        
     }  
 }
    if(caselist.size()>0)
     update caselist;
Please let me know if it helps
thanks
SANDEEP KUMAR 2391SANDEEP KUMAR 2391