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
JT-FloridaJT-Florida 

Opportunity Stage to drive Account Record Types

Any ideas on how to use the Opportunity Stage to drive the Account Record Types?

 

Need:

When Opportunity Stage = Implementation

Change Account Record Type = Customer

 

Regular workflow with a field update won't work because of being cross-objects.

Ideas would be greatly appreicated! Thank you!

hisrinuhisrinu

 

Yes you are correct, we can't achieve through workflows.

 

You can write a trigger if stagename = implementation then change the recordtype of that account.

JT-FloridaJT-Florida

Thank you Srini!

I've never written a trigger. Is it similar to creating a forumla field, but under the trigger section? And would this be an Opportunity Trigger vs. an Account Trigger? Thank you very much!

 

hisrinuhisrinu

trigger opptrigger on opportunity(after update){

list<account> acclist = new account<>();

  for(opportunity o : trigger.new)

  if(o.stagename == 'implementation'){

    account a = new account(id = o.accountid);

    a.recordtypeid = PUT your recordtype id here;

    acclist.add(a);

 }

  update acclist;

}