Ask Search:
Bill DavisBill Davis 

Process Builder to update contact field when opportunity closes

I am looking for a way to update the contact on an opportunity when the opportunity is closed won/lost.

The contacts are connected to an opportunity via the contact roles feature.

I have a picklist field at the contact level called 'Lead Status' that tracks if the contact is MQL/SQL/etc and when the opp is closed won we want this to be set to SQL-Won and if the opp is lost we want to be able to set this to be another value (Yet to be determined as we want the won portion first)

When I go into the process builder, I choose the opportunity object to start the process.  The criteria for this action is basd on the opportunity stage field = Closed won and the immediate action, I want the action tpe to update records related to the opportunity, but I cannot locate the actual contact object that I wish to update, I only see the ability to update opportunity contacts.

Is there a way to update the actual contact field on an opportunity update?
Emre hasanEmre hasan
Now since the Oppty is related to an Account seems like it cannot be done. Via the Oppty COntact role object we can only reference the ID and role ETC. 
A way round this is perhaps is 

1.Select Oppty object. 
2.Then select the Update a record ACTION
3. Key thing SELECT ACCOUNT id arrow which will take you to the account object, then scroll down to Contacts as you can see I have and select that object, since Contacts is related to Account. 


User-added image

4. You can see we have traversed up to account, then down to the Contact. On the fields section these are all Contact fields. Enter which fields you would like to update on the Contact object. 

User-added image


Try this Billy, let me know if it works! 
Thanks

 
Bill DavisBill Davis
Thanks, but how would this know which contact to update?  It seems like the logic would update all contacts for the account and not the single one that is attached to the opportunity.
Emre hasanEmre hasan
Yes thats true, if thats not the desired outcome, then the only other option is using Visual flow im afraid. 

Using Visual flow, record lookup the Contact roles assocaited to an Opportunity, then Record update the Contacts which are present at the Contact role. 

Or easiest method get a developer to acheive this, since it doesnt seem standard. 



 
Vidya IyerVidya Iyer
@Bill Davis, we have a very similar situation.

How did you resolve this?
Bill DavisBill Davis
@Vidya Iyer - We still have this as an item to resolve.
Vidya IyerVidya Iyer
Thank you @BIll Davis for your prompt response.

We are trying to implement the solution mentioned in http://succeedwithsalesforce.com/using-process-builder-and-flows-to-send-email-to-a-primary-contact-on-an-opportunity/
Will keep you posted on how that goes.
Adam TysonAdam Tyson
@Bill Davis, if I'm understanding your need correctly, then I believe Emre's answer above does have the solution.  I came across this thread a few days ago looking to accomplish the following (I have it working now, so I thought I'd come back and outline what I've done.)

My need:

- When an opportunity is created or edited and stage =/= Closed Won or Closed Lost, then update custom field "Contact Status" to "Opportunity" - but ONLY on the contact that is checked as the "Primary" opportunity contact role.

- And, if an opportunity is updated to Closed Won, then update the Contact Status of the primary opportunity contact role to "Customer."

For the first point, here are the steps I took (and if I'm over explaining, I apologize.  I don't have a ton of experience with Flow Builder, so I don't mean to explain really basic ideas):

1- Build a two-step flow. 

Step 1 is a Record Lookup, to find an Opportunity Contact Role where "Is Primary" is not null, and then also assign the found record's ContactID as a variable.  (This step is also the Starting Item)
User-added image

Flow step 2 is a Record Update on the Contact object, where the Contact ID equals the variable from step 1, then update the "Contact Status" field to "Opportunity:"
User-added image

When you save the flow, save it as type "Autolaunched Flow." 

I only want this process to apply to new opportunities that meet my criteria, so I did not manually run the flow.  


2 - Use process builder to invoke the flow.
I created a Process on the Opportunity object (created or edited), with the execution criteria of "stage is not Closed Won" and "stage is not Closed Lost."  Then, for the immediate action, I picked "Flows" and then selected my new flow.

I did figure out that you have to create the flow first, and then the process, otherwise for some reason Process Builder can't see the flow even if you refresh etc.  Creating a clone of the process worked for me.
User-added image

You didn't mention using the "Primary" contact role in your question, but you can also use the flow to look at the "Role" field on the contact role object as well.  I hope this was helpful.
Soledad AngelSoledad Angel
@adam, this is exactly what I need, but it is not working. When I ran a test, it is not pulling the right contact ID, it brings a completely random contact ID (not related to the opp or even the account). Any ideas?? 
Ben LewinskyBen Lewinsky
Same for me, I ran a test yesterday and could not get it to work. Adam if you have some more detailed instructions that would be great.
Adam TysonAdam Tyson
Hi Soledad, Hi Ben.  Please try the following modification to the process and flow above:  To the first step of the flow, add a new criteria under the "Filters and Assignments" section, also adding a new variable for opportunity ID. 
User-added image


Then, also add a new "set flow variable" to the Immediate Action of your process, assigning the opportunity ID from the triggering opp to the "OppID" variable from the flow.
User-added image
Ben LewinskyBen Lewinsky
That did the trick for me. An important note is to have your variables set to be both 'inbound and outbound' so you can access the option to set the flow variables in the process builder.
Soledad AngelSoledad Angel
Works!!!

Thank you!!
Jason McKenneyJason McKenney
Hi all,
When I try to build this flow and enter the Variable name for ContactID = {!CRcontactID}, I am told my entry is invalid. I also tried {!$CRcontactID}. Should this variable name be declared in an earlier step?

User-added image

 
Adam TysonAdam Tyson
Hi Jason, you do need to create the variable - instead of directly typing a variable into that field, just hit the dropdown menu for it.  You'll get an option for "create new" and then within that selection, an option for "variable"

User-added image
Jason McKenneyJason McKenney
Doh! Simple. Thanks Adam.
Soledad AngelSoledad Angel
Guys,
this is throwing an error. I had to deactivate as my users were not able to mark the opp as W. 

I was able to update the opp as admin, but not my users. 

Any ideas?

User-added image
Lisa LarsonLisa Larson
Hi All, I have a very similar use case to this where we are trying to update a field on the contacs that are associated to the opportunity through contact role. The promlem I'm encountering in my tests is that the process/flow is only updating one of the contacts and not all contacts associated to the specified opp. Did anyone else run into this and how did you solve for it? 

Here are my screens for record lookupUser-added image
and record update
User-added image
I have a very simple process builder step that runs if IsClosed = False 
User-added image
and invokes the flow if variable opp Id = the opp ID that's being edited
User-added image

Any ideas as to why the process would work if there's one contact but if there are multiple contacts it only runs for certain contacts? Help is much appreciated! Thanks in advance!