About

all about SFDC

Wednesday 5 June 2019

Launch/invoke flow from process builder and update child records with Flow

03:46

In this post for easier grasping I took the basic example of updating child records when parent updated. To achieve this I took a two checkbox custom fields "Read Only Account" on Account object and another custom field "Read Only Contact" on contact object. So when ever the account's field "Read Only Account" is set to true/checked then the related all contacts' field "Read Only Contact" will get updated to true/checked.

The contact update part is implemented in Flow builder and this flow is invoked from process builder which is fired/invoked when account is updated.



Process builder to invoke the Flow when "Read Only Account" field on Account is checked.



Make sure the "accId" flow variable is set to "allow input" from out side the flow when creating flow.



Created an Auto Launched flow with 3 different actions including getting/query contacts and iterating them, change field "Read Only Contact" to checked/true and then updating them in the final stage after iterating all items in loop. Ensure the loop is closed always after certain operations or assignments completed and then invoke other actions such as updates after last item finished in loop.



The break down of each stage is mentioned  in the below pictures and I skipped few steps such as creating flow variables and choosing data types. However, in this flow we use text, list of contacts and contact data types mostly. It makes sense for us which data type should we choose, when we explore the flow builder more .


In the above stage make sure "accId" flow variable is set take input from outside the flow. Specify fields to query and create a list of contacts variable to hold query returned records.



Iterate contacts and holding each record in a loop variable of contact type


 Setting field "Read Only Contact" on contact to True and adding it to a list. At this point avoid simply adding loop variable to a list for update, this doesn't work. We need to capture the fields need to update into another variable in this case variable {!tempConToUpdate} and then add this variable to a list. Never forget the Id field is required in an update call.




Updating contacts by passing previously populated list from assignment stage.


Cheers!!!

2 Comments

  1. With BOFC App | Bulk Object Field Creator user can Export (Single or Multiple) Process Builders” within same Salesforce org in few clicks

    ReplyDelete
  2. "We need to capture the fields need to update into another variable in this case variable {!tempConToUpdate} and then add this variable to a list. Never forget the Id field is required in an update call."

    I don't understand, how to do this.

    ReplyDelete

Note: only a member of this blog may post a comment.

Powered by Blogger.

Contact form

Name

Email *

Message *

Visualforce

Apex

Lightening UI

Translate

Comments