Salesforce Process Builder: Working With Process Builder – II

Process Builder is a point & click automation tool available on the Salesforce Platform. I have explained the details about the Process Builder Interface in one of my earlier blogs. I will be skipping Process Builder interface-specific details in this blog, so I would recommend you to first go through the blog. This blog is available here: Working with Process Builder - I

In this blog, we will look for another process automation solving another real-time business problem using Process Builder. Lets’ consider the problem statement below to identify the business problem at hand-

Problem Statement

While adding or modifying the point of contact for any specific Account, we need to make sure that contact must have a valid Phone Number & Email Id. If contacts don’t have Phone Number & Email Id then this information should be copied from Account Details.

Analysis of Problem Statement


In the real world as developers we would always look into the problem statement carefully to identify the best approach to solve it, so adopt it as a thumb rule.

From the problem statement we have -
  • Trigger: New Contact Record added or edited
  • Criteria: If Contact Email Id & Phone Number are empty
  • Action: Update Contact information from Account Details
    • Contact.Email = Account.Email
    • Contact.Phone = Account.Phone
Launch the Org and search for “Process Builder” in Setup Navigation on the left as shown below


This will launch the “View All Processes” screen where we can the list of all the process created earlier

Click on the “New” button


This will launch the New Process Configuration dialog box

Specify the details “Name, API Name, Description, and Process Type” for the new process.

Click on “Save” to persist the changes and start the Process designer.



To add the trigger for the Process click on “Add Object”


  1. Click Add Object
  2. Select trigger target as any desired sObject from Object Dropdown, I choose "Contact" Object based on the problem statement
  3. Select the trigger condition as when do you like to initiate the process. I choose “when a record is created or edited” based on the problem statement
  4. Click "Save" to persist the changes
To add the criteria click on “Add Criteria”


  1. Click Add Criteria
  2. Enter the name of the criteria to uniquely identifies the criteria by its function
  3. Select applicable conditions to execute actions, I choose “Conditions are met” which means that actions will be executed only when conditions are fully satisfied
  4. Configure condition based on your problem statement:
    1. Contact.Email == Null
    2. Contact.Phone == Null
We set both the values to a global constant collection which is represented by “$GlobalConstant.Null” in declarative development paradigms for Salesforce Development.


.   5. Evaluate the conditional logic to merge the conditions using logical operators.          It follows the format: Condition 1 <logical operator> Condition 2
“Customize my logic” is my preferred option since it gives me maximum flexibility to place conditions more logically in whatever way best suited the requirement.
Here I have mentioned “1 And 2”, which mean both conditions 1 & 2 must be evaluated to True to success these criteria
6. Click “Save” to persist the changes

To add the actions click on “Add Actions”


  1. Click Add Action
  2. As per the business requirement, we need to add a task, so I am selecting “Update Record” as Action Type
  3. Specify the name to uniquely identifies the action, lets’ call it “Update Contact”
  4. Since we are expecting to create a task so we need to select the sObject accordingly. In our case, we will choose “Contact” as Record Type


   5. Select the criteria for updating the records, in our case we need to update the contact record anyways. So we will choose “No criteria – just update the records!”

  6. Based on the problem statement, we need to update the Email & Phone fields of Contact Record
     

  • Email: We have set it to the reference of the “Primary Email” Field of the   Account object



  • Phone: We have set it to the reference to the “Account Phone” Field of the Account object



7. Click “Save” to persist the changes


To activate the Process click the “Activate” button in the toolbar as shown below. This action will prompt a confirmation box confirming if you wish to activate this version of the Process.


Click “Confirm” to activate this Process.


It is important to note here that Salesforce can maintain multiple versions of the same Process at the same time, but only one version will remain active.


So since we have already Activate the latest version of the Process, it now the time to test it.

Here is the test plan to validate the working of this process:

Positive Test


I am demonstrating a positive test in this demo that will satisfy the criteria of the Process and let it updates the fields of Contact Record as expected.

  1. Launch Account Object list view
  2. Click on “New” button on the toolbar to add a new Account


   3.Fill the following details:

  1. Account Name: Specify a suitable account name, I have specified “NewAccount-001”
  2. Primary Email: Specify a suitable email id for the Account
  3. Phone: Specify a suitable phone number for the Account


   4.Click “Save” to add the account


5. Once account created successfully we need to launch the Contacts Object list view

6. Click on New button in the toolbar to launch a New Contact Screen


        Fill the following details:
  • Salutation, First Name & Last Name: Enter suitable values for each of these fields
  • Account Name: This is the lookup field, use to look up for Account “NewAccount-001” that we have created recently
  • Click “Save” to persist the changes. Here it is important to notice that we haven’t specified Email & Phone Number for the new Contact
Once contact is created successfully, it triggers the process since the Email & Phone Number is missing for the Contact that we have created just now.





The process will update the Contact Details using Account Details and we should be able to see Email & Phone Number copied to the Contact Details on the Contact Screen.

Notice carefully and make sure that the phone number and email id have the same values as we have specified during Account Creation.

Negative Test


I would love to leave it for you as an exercise, and if you follow along with this article it would not be difficult for you anymore.

Hope you enjoyed this article. Please leave your comments to let me know how you do like the content and how you do find it helpful to learn the topic.

Comments