how to change the status of sc_req item dynamically in workflow ?

1dusjhyahnt
Tera Contributor

With the help of scripting i want to change the status of sc_req item dynamically with the help of scripting in workflow  , anyone help me

 

Set Value is not working in workflow 

7 REPLIES 7

Hello @1dusjhyahnt 

var itemID = current.sys_id;

var wr = GlideRecord('sc_req_item');

wr.addQuery('sys_id',itemID);

wr.query();

while(wr.next())

{

wr.state = '1';

wr.update();

}

Sumanth16
Kilo Patron

Hi @1dusjhyahnt ,


Add Run Script activity in workflow , add following script in workflow:

 

ifscript();

function ifscript(){

var item = new GlideRecord('sc_req_item');
item.get(current.request_item.sys_id);
item.state='closed';//update your value
item.update();

}

Please mark it as helpful (or) correct if it helps.

Thanks & Regards,
Sumanth Meda

kps sumanth
Mega Guru

Hello @1dusjhyahnt ,

 

If you are trying to close the same RITM for which workflow is running you can just add activity called "set field values", after the activity where you want to close the RITM, and you can just set state value accordingly.

kps2_0-1707837374610.png

Please mark this accepted if it works.