I have an after insert/after update trigger which checks for a sub-status of 'Active'. This triggers the conversion of the lead. It has been working great.

I am implementing a time based workflow rule which triggers a task to be created 21 days after the status of sold.

This is now causing an issue with the APEX code because Active is a sub-status of sold. Once the sub-status is moved to sold, the system attempts to convert the lead but can't because there is still an open time based workflow. Ideally, I'd like to include in the APEX the deletion of that time based workflow. Is there anyway to do that? Any documentation would be appreciated.

Due to the order of execution, I cannot simple add an exclusion statement to the Workflow Rule (i.e. AND(ISPICKVAL(status,"SOLD"),NOT(ISPICKVAL(sub_status__c("ACTIVE")))). The issue is that the APEX attempts to fire before it gets to cancel the workflow on it's own.

1 Answer 1


Info here

Basically you create a checkbox field on the lead and add it to the workflow rule criteria to = false.

Then either using a VF page called by overriding the convert button as in this example or via updating the lead first via code (if custom implementation already exists) to have the checkbox = true. This will delete any existing time based workflows as they are no longer meeting the criteria.

You must log in to answer this question.

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