0

Question Ultimately, in Flow, after performing a FastLookup on OpportunityContactRole and storing the result as a Sobject Collection flow Variable, how would I enhance the same flow so that it performed an efficient update on a list of Contacts determined by all the ContactIDs within the OpportunityContactRole sobject collection variable?

Here's more background on what I'm trying to achieve:

I have a process builder on Opportunity.

When Stage becomes Won I want to update a custom field on all Contacts that are OpportunityContactMembers members of the Opportunity.

Th Flow is called from Process Builder and OpportunityID is passed to the Flow.

The flow needs to updates a custom_picklist_field__c on all Contact(s) found in the Opportunity’s related OpportunityContactRoles.

This link (https://success.salesforce.com/answers?id=9063A0000019RiqQAE) is not an answer because it updates only the primary contacts.

I dont want to use Apex to perform the update on Contacts but essentially I want the Flow to achieve what (in apex) would be a DML Update made to these Contacts: SELECT ID FROM Contact where ID IN (select contactid from opportunitycontactrole where opportunityID=:oppRecordBeingProcessedByProcessBuilder)

The flow starts with a "FastLookup” of OpportunityContactRoles, finding OpportunityContactRoles WHERE OpportunityId =:OpportunityIDFlowVar.

However from here I dont know how to use Flow Designer to efficiently (preferably 1 fastUpdate) update the Contacts found in the ContactIDS within the OpportunityContactRoles. Even if I assign the result of "FastLookup OpportunityContactRoles" to a sobject collection flow variable of type OpportunityContactRole what would be the next step for updating Contacts that meet the requirement stated above? Would the next step after the fastLookup be to flow loop over its result and do what kind of assignment? Ultimately how would I loop over a sobject collection variable of Type OpportunityContactRole in flow and prepare an update for many Contacts?

Thanks for the help,

2

You have all of the ContactsRoles in an sObjectcollection. You can use a loop flow element to sort through the ContactRoles and set record values, which can be updated in bulk after the loop.

  1. You need to create an sObject collection for Contacts, and a sObject variable for Contact.
  2. Create a loop element, have it loop through the ContactRoles
  3. Create an assignment element to set the Contact sObject variable values (recordID and custom picklist)
  4. Use ANOTHER assignment element to add the Contact sObject variable to the Contact sObject collection.
  5. End the loop
  6. Fast Update the Contact sObject collection.
0

I found a similar pattern here https://focusonforce.com/process-automation/focus-on-automation-visual-workflow-loops/ which addresses my question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.