2

I have a requirement that whenever I create a Job object record (*Job is my custom object here) an approval process should be called to lock the record but after three days of the creation of record.

I tried to achieve this with the help of process builder but in this case when the job is created all the criteria are not satisfied hence the approval process is not triggered.

Please guide me how to call an approval process after three days of the creation of record

Thanks in advance

1

Here is the approach:

Approach 1

  1. Create a checkbox field let's say isFireApproval.
  2. Define a time based workflow which will fire after 72 hours based on creation date. In that action, update isFireApproval=true through workflow field update.

  3. In the workflow field update configuration section select the checkbox Re-evaluate Workflow Rules after Field Change. (otherwise, process builder's process will not fire)

  4. Create an approval process on that Job object which will also check isFireApproval=true.

  5. Define a process builder's process (when a record is created or edited) with a criteria isFireApproval=true which will submit for approval.

Process flow:

process flow

Through approval process you can lock the record.

Update based on comments

To support the Approach 1, I have created this process and it will be perfectly working.

  1. Workflow field update configuration

Workflow field

  1. Workflow rule configuration

Workflow rule configuration

  1. Approval process configuration

Approval process configuration

  1. Process builder configuration

Process builder configuration

  1. Final output

screen

Otherwise,

Approach 2

  1. Create a checkbox field let's say isFireApproval.
  2. Define a time based workflow which will fire after 72 hours based on creation date. In that action, update isFireApproval=true through workflow field update.

  3. In the workflow field update section select the checkbox Re-evaluate Workflow Rules after Field Change.

  4. Create a create trigger (after update) and lock the record using Approval.lock()

    Refer Approval Class - lock method

    Approval.LockResult[] lrList = Approval.lock(List<SObject> recordsToLock);

You can also refer my blog post in case it helps:

Locking Salesforce records for concurrent users to view or to perform any other actions .

  • Hello Santanu , I executed everything as you said but in the last step I m getting an error .The process builder is not able to call the approval process hence the flow isn't completed so when I create any record it is showing the following error : – Saswata Das May 13 '17 at 7:03
  • "Workflow Action Failed to Trigger Flow The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 301280000007zzm. Flow error messages: &lt;b&gt;An unhandled fault has occurred in this flow&lt;/b&gt;&lt;br&gt;An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help. Click here to return to the previous page." – Saswata Das May 13 '17 at 7:04
  • This is working perfectly while I am using a trigger but it would have been better if I achieved the same result using process builder – Saswata Das May 13 '17 at 9:21
  • 1
    The way I have described, Approach 1 is perfectly working, See the updated answer with the screenshot. Configuration works perfectly. – Santanu Boral May 13 '17 at 18:41
  • yes the functionality is wirking perfectly using both the approaches.Thank you for the answers – Saswata Das May 15 '17 at 5:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.