2

When a task priority is changed, I have an apex algorithm to calculate the total number of working hours for a task and the exact time when the task should be finished.

The exact time is then populated in a Task custom field called "Scheduler".

I have also a Task workflow which is activated when the Task priority is changed.

This is a Time-Dependent Workflow and the action is to send an e-mail alert one hour before the date and time in the "Scheduler" custom field.
When task priority is changed:
1. I put the date/time value to "Scheduler" custom field.
2. The mentioned workflow is activated.

What I want to achieve is when the task status is changed to "Completed" to interrupt and to stop the execution of already scheduled (from the workflow) e-mail sending.

Please advise how this can be achieved in Salesforce?

4

You should include status not equal to Completed in the rule criteria.

Refer Will the pending actions in the queue ALWAYS trigger?

Time-dependent actions remain in the Workflow Queue until processed or the rule criteria for the Workflow Rule are evaluated as "false." If a record no longer matches the rule criteria when the rule is evaluated, Salesforce removes the time-dependent actions queued for that record.

Example: An Opportunity Workflow Rule may specify:

A criteria set to "Opportunity: Status not equals to Closed Won, Closed Lost." An associated time-dependent action with a time trigger set to 7 days before the Opportunity close date. If a record matching the criteria is created on July 1st and the Close Date is set to July 30th, the time-dependent action is scheduled for July 23rd. However, if the Opportunity is set to "Closed Won" or "Closed Lost" before July 23rd, the time-dependent action is automatically removed from the queue.

1
  • Thank you for your comment, the article and the example. Appreciate your help.
    – sfdev
    Aug 30 '17 at 7:41

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