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

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

Last Updated on April 15, 2019 by Rakesh Gupta

Check out my previous articles: 

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 in Update 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:

  1. 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: 

Nope! Can not do it!

As mentioned above, one of the limitations of the process builder is that, you cannot write own filter logic in Update Records action – as shown in the preceding 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 possible if 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 GurukulOnCloudHe 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: 

  1. To create a new process from scratch, click on the New Button 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:
  2. Once you are done, click on the Save button.
  3. Click on the Object node to add object and then select the Opportunity object. For the entry criteria, select when a record is created or edited, as shown in the screenshot below:
  4. Once you are done, click on the Save button.
  5. The next task is to add Process Criteria, so that process will only fire when it meets the stated criteria. To do this click on Add Criteria, enter NameType of action and set filter conditions, follow the following screenshot for details:
  6. Once you are done, click on the Save button.
  7. Now we have to add an Immediate action to the Process to update account record. Click on Add 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 3So, as per business requirement, if the record meets the stated criteria then the process will pass Opportunity CreatedById, or else, 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.

    1. Formula used in this process – IF(
      (AND
      (NOT(ISBLANK([Opportunity].AccountId)),
      AND (CASE([Opportunity].Account.Rating,”Cold”, 1,0)=1,
      CASE([Opportunityyunity].Account.Status__c ,”Active”, 1,0)=1))
      || CASE([Opportunity].Account.Type,”Partner”, 1,0)=1
      ),
      [Opportunity].CreatedById , “”
      )
  8. Once you are done, click on the Save button. 
  9. In the end, your Process will look like the following screenshot:
  10. 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. 

Yes, go ahead! Show off your newly acquired skills to your friends, colleagues, and families!

Please feel free to add constructive comments, insights – and yes, challenges too! – to the blog. Good Luck and continue on your Journey towards becoming a formidable Salesforce Ninja!

Note: – I am grateful to Resco.net and Smartcloud.io for sponsoring my blog.

Technical Editor and Proofreader: - Munira Majmundar
Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

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

  1. Only valid if the “Equals”-operator is being used.
    This does not work with other operators like e.g. “Contains”.
    Even if the same field is used twice, in all other cases then “Equals”, SFDC applies AND, an not OR-logic.

  2. 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.

  3. 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?

    1. Make sense!

      Now what will you do in this situation – I want to update contact fields (A custom lookup with Opportunity) when

        Opprunirty Stage= Prospecting
        Contact ANnual Renenue >$1M
        Contact emal domain contains – automationchampion.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.