Announcing the Global SNUG Board of Directors. Learn more here
on 02-23-2018 11:09 AM
Script::. How to update a change_request
var objChangeRequest = new GlideRecord("change_request");
objChangeRequest.addQuery("sys_id", "bfb14d900fa0d74032854d6a42050e38");
objChangeRequest.orderByDesc('sys_created_on');
objChangeRequest.query();
objChangeRequest.next();
objChangeRequest.state.setValue("3");
objChangeRequest.setWorkflow(false);
objChangeRequest.autoSysFields(false);
objChangeRequest.update();
Not sure about this one a better/more concise way to update any record in the system ,
var gr = new GlideRecord('change_request');
if(gr.get('e9ef98dbdb545700ede2fb671d961958')){
gr.state.setValue("3");
gr.update();
}
Also since you are targeting one record with "objChangeRequest.addQuery("sys_id", "bfb14d900fa0d74032854d6a42050e38");
There really isn't any reason to use orderByDesc("sys_created_on");
Also you should mentioned that using,
objChangeRequest.setWorkflow(false);
objChangeRequest.autoSysFields(false);
Will prevent other Business rules from running and system fields not being updated. To avoid new developers from being mislead or confused by the use of these methods.