Set the Request State from a Request Item workflow

billi_lumley
ServiceNow Employee
ServiceNow Employee

Is it possible to set the Request State using Run Script from a Request Item workflow?

I tried using: current.request.request_state = 'requested';

Not working...

1 ACCEPTED SOLUTION

NeilH2
Giga Guru

Run a query to access the request table and update the state

I use this all the time to set short descriptions from a request item

var req = new GlideRecord('sc_request');
req.addQuery('sys_id', current.request);
req.query();
while (req.next()) {
req.request_state = 'requested';
req.update();
}


View solution in original post

7 REPLIES 7

How about this?



var req = new GlideRecord('sc_request');


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


req.query();


while (req.next()) {


req.request_state = current.request_state;


req.update();


}



I would avoid code with hard coded values.


Rather, I would want to copy the request_state from the RITM.



If this answer was helpful, I would appreciate if you marked it as such - thanks!

Best
Daniel

I tried that, but to no avail.


It seems that current.request_state is not updated?



If this answer was helpful, I would appreciate if you marked it as such - thanks!

Best
Daniel

billi_lumley
ServiceNow Employee
ServiceNow Employee

Perfect! Much appreciated!