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

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

Hi Ragav,

Thanks for your quick reply,

Mentioned BR working fine.

But in my current organization most catalog items RITM workflow dosen't have (Approval action- Approved) activity. That's why state is showing "Requested" only after approved RITM also(Ticked in snapshot)

 

 

Ramakrishna6_1-1669182931729.png

 

Could you please suggest solution: (when state is showing "requested" after approved RITM) Req state should be "work in progress".

 

Some trigger has to be there on RITM to make this work. If your catalog item has workflow then change the approval to approved or state to RITM to wip after approval using wotkflow.

Once this is done, run the BR according to RITM state change or approval change.


Please mark the answer correct/helpful accordingly.


Raghav
MVP 2023

On your RITM workflow after approval activity you can add the same script in "run script" activity which you added in the BR:

 

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