Duplicate workflow contexts firing

Darren Lau
Kilo Sage

Has anyone encountered this scenario before and what was your resolution?   I haven't found anything on this using the search function.   I have a business rule that uses the startFlow method in the Workflow class to execute a custom workflow by name.

var wflw = new Workflow();

(new ContractManagementUtils()).updateTermsAndConditions(current.sys_id);

wflw.startFlow(wflw.getWorkflowFromName('Contract Approval New'), current, current.operation());

I verify in logging that the business rule only executes once.   But in Workflow Contexts, there are two duplicate active contexts that get generated at the same exact time for the single contract record.   When I take action on the contract record to move the workflow past the single wait condition, only one of the two workflow contexts finishes executing.   The other context remains in the "executing" state and is still sitting in the single wait condition.   We are on Istanbul Patch 8.

1 ACCEPTED SOLUTION

In the workflow what value do you have selected for the condition?


it defaults to Run the workflow always.



If you disable your business rule do you get 1 or 0 workflows starting?


View solution in original post

4 REPLIES 4

shill
Mega Sage

Have you validated that the workflow in question does not have any conditions that would cause it to trigger outside of your business rule?


Also, I have seen this when there are two versions of the same workflow active.


Yup, no conditions at all on the workflow.   It only can fire on the business rule.   And I made sure there is only one active published version of the workflow under Workflow Versions.   Is there a better way to check to see if there are duplicate versions?   Thanks.


In the workflow what value do you have selected for the condition?


it defaults to Run the workflow always.



If you disable your business rule do you get 1 or 0 workflows starting?


Thanks Thaddeus.   It was the condition and it was set to "Run the Workflow" even though I had selected "None" when I first submitted the workflow.   After setting it back to "None" all is well again.   I must have overlooked that one part and was just looking at the field selection under it.