Scriptable service catalog variables - update a variable

 https://docs.servicenow.com/bundle/paris-application-development/page/script/server-scripting/concept/c_ScriptableServiceCatalogVariables.html


e.g. back-fill a missing variable


var gr = new GlideRecord('sc_req_item'); gr.addActiveQuery(); gr.addQuery('cat_item', '8e6430cadbaf9c1011eaa0214b96xxxx');//--general request gr.query(); var bUpdate = false; //bUpdate=true; var iCount=0; while (gr.next()) { if (gr.variables.request_type == '') { gs.print(gr.number); iCount++; if (bUpdate) { gr.variables.request_type = '38'; gr.update(); //break; } /*var set = new GlideappVariablePoolQuestionSet(); set.setRequestID(gr.sys_id); set.load(); var vs = set.getFlatQuestions(); for (var i = 0; i < vs.size(); i++) { if (vs.get(i).getLabel() != '' && vs.get(i).getDisplayValue() != '') { gs.print(vs.get(i).getName() + '; ' + vs.get(i).getLabel() + ': ' + vs.get(i).getDisplayValue()); } } */ } } gs.print('TOTAL: ' + iCount);

Comments

Popular posts from this blog

GlideRecord setValue

Running transform maps asynchronously

Post a command to the ECC queue for the mid server to initiate a powershell file copy