Skip to main content

Posts

Showing posts from December, 2023

ServiceNow Service Catalog Variables or Record Producer Variables in Client Script Using Scratchpad

 ServiceNow Service Catalog Variables or Record Producer Variables in Client Script Using Scratchpad see also:  https://docs.servicenow.com/bundle/vancouver-application-development/page/script/server-scripting/concept/c_ScriptableServiceCatalogVariables.html display business rule var varsArr = []; var variables = current . variables . getElements (); for ( var i = 0 ; i < variables . length ; i ++) { var question = variables [ i ]. getQuestion (); varsArr . push ( question . getName () + ":" + question . getLabel () + ":" + question . getValue ()); } g_scratchpad .rp variables = varsArr . toString (); //for multi row var varsMR = current . variables . getElements ( true ); var varsMR_Arr = []; for ( var i = 0 ; i < varsMR . length ; i ++) { var now_V = varsMR [ i ]; if ( now_V . isMultiRow ()) { var rows = now_V . getRows (); ...

ServiceNow RECORD PRODUCER / CATALOG ITEM VARIABLES in scripts - UPDATED VERSION

ServiceNow RECORD PRODUCER / CATALOG ITEM VARIABLES in scripts - UPDATED VERSION  see https://docs.servicenow.com/bundle/vancouver-application-development/page/script/server-scripting/concept/c_ScriptableServiceCatalogVariables.html Example to access variables of GlideRecord for the Task table var now_GR = new GlideRecord('sc_req_item'); if (now_GR.get('635a1f5387320300e0ef0cf888cb0b73')) { var variables = now_GR.variables.getElements(); for (var i=0;i<variables.length;i++) { var question = variables[i].getQuestion(); gs.log(question.getLabel() + ":" + question.getValue()) } } Example to access a multi-row variable set of GlideRecord for the Task table var now_GR = new GlideRecord('sc_req_item'); now_GR.get('02c38dcd87013300e0ef0cf888cb0bb2'); var vars = now_GR.variables.getElements(true); for (var i=0; i<vars.length; i++) { var now_V = vars[i]; if (now_V.isMultiRow()) { var rows = now_...

ServiceNow Function Fields for Database Transformations and Calculations

  ServiceNow Function Fields for Database Transformations and Calculations see https://docs.servicenow.com/bundle/vancouver-platform-administration/page/build/platform-functions/concept/platform-support-functions.html#:~:text=Function%20fields%20do%20not%20have,%2C%20reports%2C%20and%20so%20on. Create function fields and scripts in the Now Platform to perform common database transformations and calculations. Regular fields store a value in the database. Instead of storing data, a function field displays the results of a database query. Function fields do not have an associated database column. Instead, function fields generate a value based on simple computations of other fields and constants. They can be used like any other fields in the system: in forms, lists, query conditions, reports, and so on. Warning:  A function field that references another function field in the function will result in an error. Function fields don't hold data or evaluate in run-time. Example: Use ca...

ServiceNow default last updated by to 'system'

ServiceNow default last updated by to 'system' using autoSysFields(false) var grAcc = new GlideRecord ( '<your table name>' ); if ( grAcc . get ( 'sys_id' , '9b66bd7f97a6f510df843a30015<your record sysid>' )){ grAcc . status = '2' ; grAcc . sys_updated_by = 'system' ; grAcc . autoSysFields ( false ); //grAcc.status='Missing'; gs . info ( grAcc . update ()); }