4

I'm creating a license expiration system, which notifies license holders of their expiring licenses. At multiple intervals (60/30/15 for example), I will send an email to the license holder. If the license holder provides updated license dates, I want to prevent further emails from going out.

I realize there are multiple workarounds possible to do what I want to do, but each that I come up doesn't provide for an optimal user experience. The most direct way to do this is to be able to just clear out any remaining time-based workflows that haven't been executed.

Therefore, my questions are:

  1. Is it possible to remove unexecuted time-based workflow using either Visual Flow or Apex?
  2. If so, which object(s) do I need to delete or update records on?

Thank you.

1 Answer 1

6

The object you're looking for is the WorkflowTimeQueue. However, it does not appear to be accessible from Apex Code or the API, so there's no way you can clear pending entries, other than manually deleting them from the queue in Setup > Monitoring > Time-Based Workflow. Instead, you'll need to edit/modify the record so it no longer meets the criteria, at which point, all pending actions for the rule will be removed from the queue.

7
  • Is that really the only way to remove these from the queue? Would deactivating or deleting the rule also work? Commented Jul 1 at 18:17
  • 1
    @ArthurNoort The OP was asking about selectively removing entries from the queue. You can, of course, deactivate the rule(s) to nuke all future scheduled tasks, but that's not the use case they were looking for.
    – sfdcfox
    Commented Jul 1 at 18:23
  • Thanks, nuking is what I'm looking for. I deactivated the rules but I still see the queue filled with pending actions. Does it take a while to remove them? Commented Jul 1 at 18:26
  • @ArthurNoort Looks like it does require deletion, probably. See this topic: You can deactivate a workflow rule at any time. If the rule has pending actions in the workflow queue, editing the record that triggered the rule removes the pending actions from the queue. If you don't edit the record, the pending actions are processed even though the rule has been deactivated.
    – sfdcfox
    Commented Jul 1 at 18:31
  • 1
    @ArthurNoort Yeah, deactivating and doing any update will work. For example, you can export just the Id field and perform an update with no extra fields. Since the rule is inactive, the tasks will be removed from the queue.
    – sfdcfox
    Commented Jul 1 at 18:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .