Getting Started with Process Builder – Part 89 (Time-based Action for Anytime Record is Created or Edited)

Getting Started with Process Builder – Part 89 (Time-based Action for Anytime Record is Created or Edited)

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!

It is difficult to overstate the power of Process Builder. Despite that, however, Process Builder does have some limitations. In this article, we will unravel a couple of known limitations of Process Builder and create a workaround by using Process Builder and Visual Workflow.

The limitation relates to setting up Scheduled Actions. To set up scheduled actions, a process has to meet one of the following bullet points:

  • Start the process only when a record is created (1)
  • Or, start the process when a record is created or edited (2). And, in addition, select the advanced option to execute actions only when specified changes are made (3).

But, what if you want to add a scheduled action when a record is created or edited and without selecting the advanced options checkbox?

Let’s look at a real-world scenario that I recently encountered. 

Business Use Case

Before going ahead let us review the aforementioned known issue again – Process Builder updates Task – WhoId field only through inline edit but not through normal editThis mainly applies to Org where – Allow Users to Relate Multiple Contacts to Tasks and Events – feature is enabled.

In light of the above-known issue framework, let us now look at a business case.

Edward Backhouse is working as System administrator at GurukulOnCloudAt GurukulOnCloud they are using Mircosoft Office 365 as their email client. Using Third-party applications they are syncing Salesforce – Microsoft Outlook calendar. They have enabled, Allow Users to Relate Multiple Contacts to Tasks and Events feature in Salesforce. 

Edwards created a process in the past to update WhoId/NameID to null (similar to what is explained in the Salesforce known issue) when Subject contains a word Outlook, but because of the above-known issue, it is no longer working. 

A solution for the above business requirement

There are few possible solutions for the above business scenario – at least two as per my understanding. The first solution will look like the following screenshot: 

The above solution will work in the most cases but, in my case, it did not work in all scenarios. So I used the second solution, which I am going to explain in the article – How to add time-dependent action to a Process which Start when a record is created or edited and advanced option checkbox is not selected.

Before we proceed further, let us understand the characteristics of a TaskRelation Object. It represents a person (a user, lead, or contact) or a resource (such as a conference room) invited to a task.

  1. Navigate to Setup (Gear Icon) | Setup | PLATFORM TOOLS | Process Automation | Flows. Click on the New Flow button; it will open the Flow canvas for you. Create variables in the Flow, as shown in the following table:
    Name Variable type Object type Input/Output type
    VarTTaskId Text Not applicable Input and Output
  2. Now we will use the Wait element to create time-dependent action, as shown in the following screenshot: 
  3. Once you are done, click on OK button. 
  4. The next step is to use a Record Delete element to remove WhoId/NameID. Drag-and-drop Record Delete element to delete all records associated to a Task through WhoId, as shown in the following screenshot: 
  5. Once you are done, click on OK button. 
  6. Use connectors to connect the elements used in the Flow. Finally, your Flow will look like the following screenshot:
  7. Once done, Save the flow and name it Clear WhoId, with Type: Autolaunched Flow. Do not forget to activate the Flow by clicking on the Activate button.
  8. The next step is to create a process, that will fire when a task subject contains a word – Outlook. To do this, Navigate to Setup (Gear Icon) | Setup | Process Automation | Process Builder
  9. 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 Clear WhoId Process as the name)API Name and Description as shown in the screenshot below:
  10. Once you are done, click on the Save button.
  11. Click on the Object node to add object and then select the Task object. For the entry criteria, select when a record is created or edited, as shown in the screenshot below:
  12. Once you are done, click on the Save button.
  13. 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:
  14. Once you are done, click on the Save button.
  15. 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 Flows), and then fill the values into fields to define the action – as shown in the following screenshot:
  16. Once you are done, click on the Save button. 
  17. In the end, your Process will look like the following screenshot:
  18. Do not forget to activate the Process by clicking on the Activate button.

P.S.:- The only part missing in this flow is to check TaskRelation record before deleting it. I removed those parts from this article to keep it brief.

It’s time to test this feature

Next time, when Task records are created or updated by the user, the process and flow which we created will fire and check the criteria – does the subject contains a word Outlook? – if so then, it will set WhoId/Name to null, as shown in the video:

Wasn’t that a great journey? Now you know how to create a time-based action for a process which Start when a record is created or edited. 

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!

One thought on “Getting Started with Process Builder – Part 89 (Time-based Action for Anytime Record is Created or Edited)

  1. Hi Rakesh,

    Thank you for taking the time to share your wisdom about PB. I have a question about time-dependent actions and lead conversions.
    Do you know a workaround to convert leads that are in a queue triggering an email notification 60 hours after lead creation if there is no activity attached to them during that time frame?

    Thanks,
    Fred

Leave a Reply

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