0

I'm trying to figure out how to update a Contact field when a related Account field is updated. This is probably trivial for seasoned Salesforce admins...

Under Accounts I have a Lookup field called "Primary Contact" which allows you to pick any Contact.

Under Contacts I have Picklist field called "Contact Type" with the options "Primary Contact, Previous Primary Contact".

How can I update the picklist field value when a change happens on the Account record?

E.g if a new contact is selected, the Contact Type field for the current Contact should be updated to "Previous Primary Contact" and the newly selected contact should be updated to "Primary Contact".

In (terrible) pseudo code, I'm try to achieve the following:

On Account update
If Primary Contact field is updated, then
Set old contact to "Previous Primary Contact"
Set new contact to "Primary Contact"

Sorry if the explanation isn't clear, I'm struggling to make sense of how to do it myself. I've tried doing this using Process Builder, but it doesn't seem to let me update a Contact's field when an Account is updated. Am I missing something? Or is this only possible using Apex code? If it's the latter, any pointers would be appreciated. Thank you!

1 Answer 1

0

You can use process builder to update a related record (the Contact). However, you CANNOT update an old value after the change has been made. IE: if an Account has the Primary Contact set to Contact A, and the value is changed to Contact B, you can only update Contact B directly within the Process Builder.

You could use a flow or Apex code to accomplish this. In either, when the Account has the primary contact changed, you'd query for all Contacts on that Account where Contact Type = Primary, but weren't equal to the current Primary Contact. Then update them to Previous Primary Contact.

I'd recommend trying this in a sandbox, not directly in your live Salesforce site. Also, you can make the Flow triggered by process builder, which makes it easier to control the criteria, deactivate, etc.

Good luck!

1
  • Hi @JimG, thanks very much. I'll set up a sandbox and start learning some Apex coding 😅 Oct 19, 2020 at 8:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .