Workflows for Standard, Normal and Emergency change requests are getting cancelled when it reaches "Wait for Condition" activity


Description

Workflows for Standard, Normal and Emergency change requests are not working as expected in one of the customers domains. the workflows are getting cancelled when it reaches "Wait for Condition" activity

Cause

Custom state values were configured on the affected domain which caused a business rule to cancel the workflow

Resolution

Reproduced the issue with debug and found the following:
When changing state to Assess an error msg is displayed : 1 Workflow for CHG173965 has been cancelled
And the State updates to Scheduled
When state changes to Scheduled the below br runs and cancels the workflow

This business rule is generating the error msg.
Business Rule
Cancel Workflows Upon Cancellation
https://remoteitmgmtdev.service-now.com/nav_to.do?uri=sys_script.do?sys_id=69527269c0a80a663a2d934e33801ced


Br conditions:

(current.getTableName() != 'sysapproval_group') && (current.getTableName() != 'rm_release') && (current.getTableName() != 'incident') && (current.getTableName() != 'problem') && (current.state.changesTo(4))

BR code:

cancelMyWorkflows();

function cancelMyWorkflows() {
//get workflow helper
var workflow = new Workflow();
//cancel all my workflows
var numCnxd = workflow.cancel(current);
if (numCnxd > 1)
gs.addInfoMessage(gs.getMessage("{0} Workflows for {1} have been cancelled", numCnxd, current.getDisplayValue()));
else if (numCnxd == 1)
gs.addInfoMessage(gs.getMessage("1 Workflow for {0} has been cancelled", current.getDisplayValue()));


Custom state values were configured for the domain

OOB State 4 = Canceled
on customers domain the State value 4 = Scheduled

The cause is that when the workflow sets the State to Scheduled, business rule condition (current.state.changesTo(4)) is met which causes the OOB Cancel Workflows Upon Cancellation business rule to run and cancel the workflow.

Since custom state values were created, the business rule condition also has to be modified to accommodate the custom state.