5 min read

In this article by Rakesh Gupta, the author of the book Learning Salesforce Visual Workflow, we will discuss how to auto update child records using Process Builder of Salesforce.

There are several business use cases where a customer wants to update child records based on some criteria, for example, auto-updating all related Opportunity to Closed-Lost if an account is updated to Inactive. To achieve these types of business requirements, you can use the Apex trigger. You can also achieve these types of requirements using the following methods:

  • Process Builder
  • A combination of Flow and Process Builder
  • A combination of Flow and Inline Visualforce page on the account detail page

(For more resources related to this topic, see here.)

We will use Process Builder to solve these types of business requirements. Let’s start with a business requirement.


Here is a business scenario: Alice Atwood is working as a system administrator in Universal Container. She has received a requirement that once an account gets activated, the account phone must be synced with the related contact asst. phone field. This means whenever an account phone fields gets updated, the same phone number will be copied to the related contacts asst. phone field.

Follow these instructions to achieve the preceding requirement using Process Builder:

  1. First of all, navigate to Setup | Build | Customize | Accounts | Fields and make sure that the Active picklist is available in your Salesforce organization. If it’s not available, create a custom Picklist field with the name as Active, and enter the Yes and No values.
  2. To create a Process, navigate to Setup | Build | Create | Workflow & Approvals | Process Builder, click on New Button, and enter the following details:
    • Name: Enter the name of the Process. Enter Update Contacts Asst Phone in Name. This must be within 255 characters.
    • API Name: This will be autopopulated based on the name.
    • Description: Write some meaningful text so that other developers or administrators can easily understand why this Process is created.

    The properties window will appear as shown in the following screenshot:

  3. Once you are done, click on the Save button. It will redirect you to the Process canvas, which allows you to create or modify the Process.
  4. After Define Process Properties, the next task is to select the object on which you want to create a Process and define the evaluation criteria. For this, click on the Add Object node. It will open an additional window on the right side of the Process canvas screen, where you have to enter the following details:
    • Object: Start typing and then select the Account object.
    • Start the process: For Start the process, select when a record is created or edited. This means the Process will fire every time, irrespective of record creation or updating.
    • Allow process to evaluate a record multiple times in a single transaction?: Select this checkbox only when you want the Process to evaluate the same record up to five times in a single transaction. It might re-examine the record because a Process, Workflow Rule, or Flow may have updated the record in the same transaction. In this case, leave this unchecked. This window will appear as shown in the following screenshot:
  5. Once you are done with adding the Process criteria, click on the Save button. Similar to the Workflow Rule, once you save the panel, it doesn’t allow you to change the selected object.
  6. After defining the evaluation criteria, the next step is to add the Process criteria. Once the Process criteria are true, only then will the Process execute the associated actions. To define the Process criteria, click on the Add Criteria node. It will open an additional window on the right side of the Process canvas screen, where you have to enter the following details:
    • Criteria Name: Enter a name for the criteria node. Enter Update Contacts in Criteria Name.
    • Criteria for Executing Actions: Select the type of criteria you want to define. You can use either a formula or a filter to define the Process criteria or no criteria. In this case, select Active equals to Yes. This means the Process will fire only when the account is active. This window will appear as shown in the following screenshot:
  7. Once you are done with defining the Process criteria, click on the Save button.
  8. Once you are done with the Process criteria node, the next step is to add an immediate action to update the related contact’s asst. phone field. For this, we will use the Update Records action available under Process. Click on Add Action available under IMMEDIATE ACTIONS. It will open an additional window on the right side of the Process canvas screen, where you have to enter the following details:
    • Action Type: Select the type of action. In this case, select Update Records.
    • Action Name: Enter a name for this action. Enter Update Assts Phone in Action Name.
    • Object: Start typing and then select the [Account].Contacts object.
    • Field: Map the Asst. Phone field with the [Account]. Phone field.

    To select the fields, you can use field picker. To enter the value, use the text entry field. It will appear as shown in the following screenshot:

  9. Once you are done, click on the Save button.
  10. Once you are done with the immediate action, the final step is to activate it. To activate a Process, click on the Activate button available on the button bar.

From now on, if you try to update an active account, Process will automatically update the related contact’s asst. phone with the value available in the account phone field.

Summary

In this article, we have learned the technique of auto updating records in Process Builder.

Resources for Article:


Further resources on this subject:


LEAVE A REPLY

Please enter your comment!
Please enter your name here