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
Stuart GrimshawStuart Grimshaw 

How do I update an account from a Quote's approval process?

As a final step in our approval process for a quote I'd like to be able to update the account and set the Type to "Customer", I know I can't do it with a field update because both relationships between Quote/Opportunity & Opportunity/Account are lookups and not master/data.

Is there a best practice for this kind of thing, I would imagine it's a pretty common thing to want to do?
Best Answer chosen by Stuart Grimshaw
Ray GuyRay Guy
You're going to be looking at using an apex trigger I'm afraid...  here are some rough steps that come to mind (unless someone can think of something more elegant?)   I'll fill in the detail when I have a moment...

1.   Create new custom field on Quote (and Opportunity) called "Change Account type to".  Don't add it to any layouts (i.e. it's hidden)
2.   In your approval process set the final step to update the Quote / Opportunity "Change Account Type to" field to "Customer"
3.   You'll need a trigger now!  Create an "on update" trigger on Quote
4.   Detect if the Change Account Type to field has changed value
5.   If so, update the Record Type of the Account via the lookup relationship
6.   Save changes the Account

I'm guessing it's steps 4/5 you'll need a hand with.  As I say, I'll try and flesh this out when I have a spare minute.

Cheers,
Ray

All Answers

Ray GuyRay Guy
You're going to be looking at using an apex trigger I'm afraid...  here are some rough steps that come to mind (unless someone can think of something more elegant?)   I'll fill in the detail when I have a moment...

1.   Create new custom field on Quote (and Opportunity) called "Change Account type to".  Don't add it to any layouts (i.e. it's hidden)
2.   In your approval process set the final step to update the Quote / Opportunity "Change Account Type to" field to "Customer"
3.   You'll need a trigger now!  Create an "on update" trigger on Quote
4.   Detect if the Change Account Type to field has changed value
5.   If so, update the Record Type of the Account via the lookup relationship
6.   Save changes the Account

I'm guessing it's steps 4/5 you'll need a hand with.  As I say, I'll try and flesh this out when I have a spare minute.

Cheers,
Ray
This was selected as the best answer
Stuart GrimshawStuart Grimshaw
I'd guessed as much, thanks Ray. If I get stuck I'll post back here.