Closed Request Item is not closing Request

Gemma4
Mega Sage

Hi,

I have noticed that when the request- request state is is changed to closed complete or closed skipped or closed rejected the Request Item state is not getting closed and marked inactive . However when the request state changes to closed cancelled it is changing request state automatically closed incomplete and ritm state changes to closed incomplete and closes any related sctask. If all catalog tasks related to the request item are closed it will close the request item but the problem is -if the request -request state is closed, it is not closing any ritm or tasks. 


What is the name of the business rule that checks to see if all child records are closed before it closes the parent? 
I checked the Set Active Flag but it is using stage and the req item table. Any suggestion? 


Thanks!

 
2 REPLIES 2

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @Gemma4 ,

 

This one of the business rule to check for request state/stage changes. So take a look. Also you can check OOTB workflows and flow or even custom as well which are responsible.

 

https://instance_name.service-now.com/nav_to.do?uri=sys_script.do?sys_id=19a9ecb40a0a0a65013c62ab86e...

 

Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.


Regards,

Siddhesh

Hi @Siddhesh Gawade 

It looks like this script is utilizing stage, see below. We are changing request.state and then need that to trigger stage. I would prefer to not edit the flows since they are each custom. Can I get help with the script for a new business rule to change  related items to closed/inactive when the closed request states change? I tried the following attached with no luck..see attached. 

 

oob 

Set Request State

setDesiredState();
 
function setDesiredState() {
    var desired = getDesiredState();
    gs.debug("DESIRED = " + desired);
    current.request_state = desired;
}
 
function getDesiredState() {
    var desired = current.request_state;
    if (desired == 'closed_cancelled') // if we're cancelled we're cancelled
        return desired;
 
gs.debug("APPROVAL = " + current.approval + " CHANGES = " + current.approval.changes());
    gs.debug("CURRENT STAGE = " + current.stage);
 
    if (current.approval.changesTo('approved')) {
        desired = 'in_process';
    } else if (current.approval.changesTo('rejected')) {
        desired = 'closed_rejected';
        current.stage = 'closed_incomplete';
        current.state = 4;
    } else if (current.stage == 'closed_complete') 
         desired = 'closed_complete';
else if (current.stage == 'closed_skipped')
desired = 'closed_skipped';
else if (current.stage == 'closed_incomplete')
desired = 'closed_incomplete';
 
    return desired;
}brtest.png