Update the State field from New->Assess->..->... in the Change Request from Scripted REST msg

KausikSharma
Tera Contributor
(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {

    // implement resource here
    var data = JSON.parse(request.body.dataString);

    var number = data.id;
    //var state = data.state;

    var gr = new GlideRecord('change_request');
    gr.addQuery('number', number);
    gr.query();
	if(gr.next()){
		gr.state = "-2";
		gr.update();
	}

})(request, response);

Hello All,
My looking for some solution that I want to update the State field from scripted REST message . Want to modify in this way New-->Asses-->Authorization. 
Using State field's value like (New:'-5', 'Assess':'-4' etc.) I tried to modify but it doesn't reflect changes to 'Assess' but directly jump to the next step Authorization.
Is there any suitable and easy way to make this happen? please share your codes and ideas

Thank you
Here is my simple code for testing

 

 

(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {

    // implement resource here
    var data = JSON.parse(request.body.dataString);

    var number = data.id;
    //var state = data.state;

    var gr = new GlideRecord('change_request');
    gr.addQuery('number', number);
    gr.query();
    if(gr.next()){
        gr.state = "-2";
        gr.update();
    }

})(request, response);

 

2 REPLIES 2

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

Please check the type of change you are updating and if the state is changed from form view does it changes from new to assess?

 

shalinig05
Tera Contributor

Any solution for this?