Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Flow designer stage not updated by business rule

cnshum
Tera Contributor

Hi 

 

I am using a business rule to set the RITM stage = request cancelled when my sctask state = closed incomplete. On the RITM stage, it is set as request cancelled but in the flow sequence, the stage does not advance to request cancelled. For the flow stages, I am using the OOB sc_req_item stage set.

 

1. business rule

cnshum_0-1715670539486.png

script for business rule: 

(function executeRule(current, previous /*null when async*/) {
 
    var ritm = current.request_item.getRefRecord();

    if(ritm.state != 4 && ritm.stage != 'Request Cancelled' ){

        //set ritm stage = request cancelled and state = closed incomplete
        ritm.state = 4;
        ritm.stage = 'Request Cancelled';
        ritm.update();

        //set req state = closed incomplete
        var req = current.request.getRefRecord();
        req.state = 4;
        req.update();

        var ritmNumber = current.request_item.number;
        var sctaskNumber = current.number;
        gs.info(ritmNumber + " - " + sctaskNumber + " is closed incomplete");
        gs.info(ritmNumber + " - state is closed incomplete");
    }

})(current, previous);
 
 
On the RITM stage, it is set as request cancelled but in the flow sequence, the stage does not advance to request cancelled.
 

cnshum_1-1715670707720.png

 

flow stage:

 

cnshum_2-1715670750743.png

 

 
 
 

 

6 REPLIES 6

Sohail Khilji
Kilo Patron

Hi @cnshum,

 

Did you set the value of stage in flow ?

did you use update record after that ?

 

May be the flow has not recevied the update and hence it did not move the stage. Try and let me know.


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi 

 

I am updating the stage using the business rule. Is that not sufficient? Or I need to set the stage in the flow as well?

my be the update on BR is not obained.


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Ok I have tried setting the stage using both the BR and flow designer. Now I am seeing 2 "request cancelled" stage