Goran WitchDoc
ServiceNow Employee

Hi,



First, Best way to do this I would say is through the workflow which I guess you have for this.



But if you want to this with a BR for some reason this would work.



The reason it aint working for you is that the table "sc_request" where the requests is, doesn't have a field called request_item. Easiest way to see this is that you go to "tables" and find the sc_request there and see what it contains. Or open up a request and look at what fields there are.



var gr = new GlideRecord('sc_request');


//Here you can use get() since you know you only will get 1 record.


gr.get(current.request); //This is the field on the RITM that contains the connection to the request



gr.request_state = 'closed_rejected';//Remember to use the value of the state and not the label


gr.state = '4': //the value of "canceled".


gr.update();



Try and let me know



//Göran