Skip to main content

Posts

Recent posts

ServiceNow get a list of item_option_new sysids based on question_answer sysids from records

 ServiceNow get a list of item_option_new sysids based on question_answer sysids from records var endUserContainerSYSID = 'b902aa3ac3058b505c97bdac05013142'; var endUserReqSYSID = '2122627ac3058b505c97bdac0501310c'; var entitlementACRSYSID = '9f22a27ac3058b505c97bdac050131d1'; var roleACRSYSID = '6712ee3ac3058b505c97bdac0501313a'; var sEncQuery = 'table_sys_id=' + endUserContainerSYSID + '^ORtable_sys_id=' + endUserReqSYSID + '^ORtable_sys_id=' + entitlementACRSYSID + '^ORtable_sys_id=' + roleACRSYSID; var sysIDs = ''; var grQA = new GlideRecord('question_answer'); grQA.addEncodedQuery(sEncQuery); grQA.query(); while (grQA.next()) {   var ret = getItemOptionNewSYSIDs(grQA.question + '');   sysIDs = sysIDs + ret + ','; } var sListViewURL = 'https://dev183654.service-now.com/item_option_new_list.do?sysparm_query=sys_idIN' + sysIDs; gs.info ('FINAL URL: ' + sListViewURL); functi...

ServcieNow Getting Record Producers - Simple v Comples

 var recSYSID = '1ba630c0c301c3105c97bdac050131a5'; var table = 'x_cls_clear_skye_i_group_operations'; getVarsSimple(recSYSID,table); getVarsComplex(recSYSID,table); function getVarsSimple(recSYSID, table) {   var now_GR = new GlideRecord(table);   gs.info('getvars SIMPLE:');   if (now_GR.get(recSYSID)) {     var variables = now_GR.variables.getElements();     for (var i = 0; i < variables.length; i++) {              var question = variables[i].getQuestion();       if (!gs.nil(question)&&question!=''){       gs.info('VARIABLE NAME:' + question.getLabel() + ", VARIABLE VALUE:" + question.getValue());       }     }   } } function getVarsComplex(recSYSID, table) {   var producerVars_allVars = new GlideRecord('question_answer');   producerVars_allVars.addQuery('table_sys_id', recSYSID);   //producerVars_allVars.addQuery('question.ty...

ServiceNow getMD5Hex function

  getMD5Hex  is a function commonly found in utility libraries (such as Apache Commons Codec) that  calculates the  MD5 hash  of data (like a string or file) and returns the result as a 32-character hexadecimal string  Example: var sname = 'Joe Bloggs'; var value = new GlideDigest().getMD5Hex(sname.toLowerCase()); gs.info ('result==='+value); ServiceNow

Why objects can’t upgrade (ServiceNow)

ServiceNow unable to revert an object to baseline during an upgrade - presented with an error When a hotfix was provided on a protected script for example look at the hotfix update set to check if the Replace on upgrade flag is set to true for that file in the update set?  If it is set to false it can cause this issue.  If it is false change the flag in the update set to true which should allow the file to be reverted to the baseline, release version. Just setting the flag in the already-applied update set seems to do the trick --- Additional info (via ServiceNow Support): vSOLUTION PROPOSED:  After analysing the logs at the time of the upgrade,  we saw that the objects was loaded but the version was not added since it is a duplicate of the latest existing ones. Example for sys_script_include_d026e995472f95d4207ddfbd436d43cf : 2026-03-19 23:07:23 (694) worker.1 worker.1 txid=e862f2ec87fb ESLatestScriptLoader Skipping sys_es_latest_script record because there is an ex...

ServiceNow Executing a Flow Action via Script (Async and Sync)

 ServiceNow Executing a Flow Action via Script (Async and Sync) Diff between asynch v synch   //-- Start Asynchronously: Uncomment to run in background. Code snippet will not have access to outputs.                   //-- sn_fd.FlowAPI.getRunner().action('global.glidepath__create_sso'). inBackground ().withInputs(inputs).run();                     //-- Execute Synchronously: Run in foreground. Code snippet has access to outputs.                   var   result = sn_fd. FlowAPI .getRunner().action( 'global.glidepath__create_action' ). inForeground ().withInputs(inputs).run();                   var   outputs = result.getOutputs();     ...