Close REQUEST when RITM is closed

Gurpreet Kaur5
Tera Expert

Good afternoon, 

 

I have created a flow where when the SC is closed, it will close the RITM.

However i am struggling to add the steps where - After the RITM is closed, it should close the REQ 

GurpreetKaur5_0-1701347913936.png

 

When i am trying to add the Action, i do not see REQ in the Data pill to choose-

GurpreetKaur5_1-1701348012256.png

 

Please advise how can i add the REQ to close please.

One of my colleague said it should automatically close REQ, which is not happening either, hence working on the flow 

1 ACCEPTED SOLUTION

Hi Danish, 

 

I created a new BR using  this script - 

(function executeRule(current, previous /*null when async*/ ) {
    var grReq = new GlideRecord('sc_request');
    grReq.addQuery('sys_id', current.request);//get the request from RITM
    grReq.query();
    if (grReq.next()) {
        grReq.request_state = 'closed_complete'; //add your field  name
        grReq.update();
    }
})(current, previous);
 
I tested it and managed to close the REQ.
 
Hope it wont conflict with other BRs

View solution in original post

4 REPLIES 4

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Gurpreet Kaur5 

 

Greetings!!

 

Could you please check the OOTB Flow , may be you need to set the stages as well. 

 

https://INSTANCENAME.service-now.com/$flow-designer.do?sysparm_nostack=true#/flow-designer/30f3d2618...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi Atul, 

 

I couldn't manage to open the page. I changed the instance name too, but no good. 

 

I checked there's an OOB BR which was enabled but it did not close the REQ as needed. 

 

I created a BR using this (which i saw in another post ) - 

(function executeRule(current, previous /*null when async*/ ) {
    var grReq = new GlideRecord('sc_request');
    grReq.addQuery('sys_id', current.request);//get the request from RITM
    grReq.query();
    if (grReq.next()) {
        grReq.request_state = 'closed_complete'; //add your field  name
        grReq.update();
    }
})(current, previous);
 
It worked for me. 

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Gurpreet Kaur5 ,

 

you can instead create a BR on RITM table n trigger when state is changed to closed complete. In advanced section u can write this script 

var gr = new GlideRecord('sc_request');
gr.addQuery('sys_id',current.request);
gr.query();
if(gr.next()){
gr.state = 'closed_complete'; // update backedn value of closed complete
gr,update();
}

 

Thanks,

Danish

 

Hi Danish, 

 

I created a new BR using  this script - 

(function executeRule(current, previous /*null when async*/ ) {
    var grReq = new GlideRecord('sc_request');
    grReq.addQuery('sys_id', current.request);//get the request from RITM
    grReq.query();
    if (grReq.next()) {
        grReq.request_state = 'closed_complete'; //add your field  name
        grReq.update();
    }
})(current, previous);
 
I tested it and managed to close the REQ.
 
Hope it wont conflict with other BRs