In the aforementioned articles, I have discussed few advanced concepts that will help you to optimize your process. If you didn’t get a chance to read it yet, do it now! It will significantly improve your knowledge of Process Builder. Once you master the art of leveraging process builder, you will be able to easily create an optimized process!

In this article, we will unravel a known limitation of process builder by understanding the logic behind using filter conditions inUpdate Records action.

As far as Update Records action goes, currently, as of (Spring’18 release), only the following two scenarios are possible in process builder:

When you use a field once, while filtering Update Records Action, then, the process builder will automatically use an ‘AND’ condition between the fields. For example, as shown in the following screenshot, both the fields (Rating and Source) are used once – and therefore, an AND condition is automatically used between them.

However, there may be times when a user may encounter a scenario where, s/he may need to use a field twice, as shown in the following screenshot:

In the above scenario, the Source field is used twice. In such a scenario, the process builder automatically creates an OR condition between first and the second use of the Source Field.

Remember, everything happens automatically so, you do not need to define anything.

Now what happens if I use three different fields, where each field is used only once, to define my filter as shown below?:

In this case, the process builder will use an ‘AND’ condition between all the three fields because they are all used only once while filtering the Update Record Action, as shown in the preceding screenshot.

Got it?

But, now, what if I want to define my own criteria? – as shown in the following screenshot:

However, we are Salesforce Ninjas and that means, we do not accept ‘can not do it’ without a good try/fight!

So, wait for a second, and think! Is it possible to solve the above business use case using process builder? – if your answer is still no, or even maybe, – then, read-on! It is possible that when you reach at the end of the article you may hear yourself saying – Yes, it is possible!

Always remember, impossible can transform into I’m possibleif you don’t give up! That is exactly what I am going to show you how to do via this blog!

Let us work through this via a business use case

Business Use Case

Edward Backhouse is working as System administrator at GurukulOnCloud. He has received the following requirement:

Whenever an Opportunity is created/updated with a Stage value prospecting then, update the Account Description field to Yes I Can!,only if, the Account fields meet the following conditions:

Account Rating = Cold AND Status = Active

OR

Account Source = Partner

A solution for the above business requirement

There are few possible solutions for the above business scenario – for instance, a User can write a trigger using Apex code that would bypass the process when a logged-in User is a System Administrator.

Most users, however, are not proficient in Apex; and, unfortunately, as discussed above, there is no apparent declarative way to solve the problem. Except one! As discussed below:

To create a new process from scratch, click on the NewButton available on Process Management page. A popup will appear where you have to enter the Name (Use Filter logic in Updating Records action as the name), API Name and Description as shown in the screenshot below:

Once you are done, click on theSave button.

Click on theObjectnode to add object and then select theOpportunityobject. For the entry criteria, select when a record is created or edited, as shown in the screenshot below:

Once you are done, click on theSavebutton.

The next task is to addProcessCriteria, so that process will only fire when it meets the stated criteria. To do this click onAdd Criteria, enter Name, Type of action and set filter conditions, follow the following screenshot for details:

Once you are done, click on theSavebutton.

Now we have to add an Immediateaction to the Process to update account record. Click onAdd Action(Under Immediate actions), Select the type of action (In our case Update Records), and then fill the values into fields to define the action – as shown in the following screenshot:To filter the record, instead of selecting the fields, I am using a formula. But the biggest question is why I have used the CreatedById field? The simple answer is, that the CreatedById field is never changed once record gets created in Salesforce (It is true for most orgs). I am using a formula to write my custom logic (1 AND 2) OR 3. So,as per business requirement, if the record meets the stated criteria then the process will pass Opportunity CreatedById, orelse, if the stated criteria is not met, then, the formula will pass a blank value.In simple words. I am comparing CreatedById=CreatedById that’s it.

Do not forget to activate the Process by clicking on the Activate button.

It’s time to test this feature

Next time, when Opportunity records are created or updated by the user, the process we created (Using Process Builder) will fire and check the criteria – does the opportunity stage equals to Prospecting? – if so then, the system will check the logic written for Update Record Action i.e.(Account Rating = Cold AND Status = Active)OR (Account Source = Partner). If the Account record meets any of these criteria it will update the Description field, as shown in the video:

Wasn’t that a great journey? Now you know how to write your own filter logic when using Record Update Actions.

5 thoughts on “Getting Started with Process Builder – Part 87 (Untangling the Perplexing Filter Logic of ‘Updating Records Action’!)”

Sid

Thanks for this article Rakesh. I have a question considering process builder will process these records in a batch operation. Will it cause any issue considering there could multiple records created by the same user hence they will have the same createdbyid.

Rakesh Gupta

Rakesh, Why wouldn’t you simply use multiple criteria in your entry node in this instance? Since Account is the Parent of Opportunity, you could put the initial criteria as Stage = Prospecting, Account Rating = Cold, Status = Active, Account Source = Partner then use filter logic of 1 AND ((2 AND 3) or 4), then use the update action. It seems this approach would be simpler in this business case…Thoughts?