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.