Req state should be changed "open" to "work in progress"

Ramakrishna6
Tera Contributor

After raised request from catalog item, state in req page showing open(ticked in snapshot)

Ramakrishna6_0-1669177819700.png

 

Now my requirement is:  After approved RITM, state in Req page should show "work in progress"(tiked in snapshot for reference)

Ramakrishna6_1-1669178853301.png

 

 

 

Ramakrishna6_2-1669179000498.png

 

Please suggest how to achive solution for this.

 

 

2 ACCEPTED SOLUTIONS

RaghavSh
Kilo Patron

when your RITM is approved does your state on RITM changes or does the approval status on RITM changes to approved? (because some trigger on RITM is required). If yes you can write after update BR on request item with below code:

 

condition :  approval changes to approved.

 

var req = new GlideRecord('sc_request');

req.addQuery('sys_id',current.request);

req.query();

if(req.next())

{

req.state = 2;

req.update();

}


Raghav
MVP 2023

View solution in original post

Hi @Ramakrishna6 ,

 

Add run script activity after approval is approved activity and write down below code in that:-

 

var gr = new GlideRecord("sc_request");
gr.addQuery('sys_id',current.request);
gr.query();
if (gr.next()) {
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.state = '2' ;  //Work in progress backend value
gr.update();
}

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

View solution in original post

9 REPLIES 9

You can create an After Update BR on Approval table and make it work only for RITMs.

 

When the state of the approval changes to Approved, you can query the assoicated Request of the RITM and change the state accordingly. Should work fine.

 

Regards,

Rana

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Ramakrishna6 ,

If you are using the workflow then handle this situation using workflow activity to set the value after approval approved.


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Could you please explain clearly, I want Req state field should be "work in progress" But we add activity in RITM workflow that is not reflected to Req page right

in which workflow(Req or RITM) i need to add "set values" activity and where exactly i need to add activity in workflow.

 

Hi @Ramakrishna6 ,

 

Add run script activity after approval is approved activity and write down below code in that:-

 

var gr = new GlideRecord("sc_request");
gr.addQuery('sys_id',current.request);
gr.query();
if (gr.next()) {
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.state = '2' ;  //Work in progress backend value
gr.update();
}

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Hi Gunjan,

Your run script code working fine.

Now state field in Req page showing "work in progress".

Generally (Approval is approved) we can achive using "Approval action" (or) "Set Values" activity in workflow

Could you please suggest how to achive this activity(Approval is approved) through Run script.

I need to achive both (Approval is approved) function and Req state (work in progress) function through runscript only.