Posts

Showing posts from September, 2020

GlideappVariablePoolQuestionSet features (Service Catalog variables)

  var emptyVariables = []; var readonlyVariables = []; var keys = []; var set = new GlideappVariablePoolQuestionSet (); set . setRequestID ( current . request_item ); set . load (); var vs = set . getFlatQuestions (); for ( var i = 0 ; i < vs . size (); i ++) { var sDisplVal = vs . get ( i ). getDisplayValue (). toString (); //--Display Value var sLabel = vs . get ( i ). getLabel (). toString (); //-- label text var sField = vs . get ( i ). getName (). toString (); //--variable name (e.g. requested_for) }

Pull variables into catalog tasks (outside workflow block)

 set the variable to global=true, assuming not using a task create block in workflow (in which case use the slushbucket)

Display Business Rule and Client Script - hide empty variables on cat item form and make visible vars read only

BUSINESS RULE (Display) - generates the scratchpads which are passed to the client script ( function executeRule ( current , previous /*null when async*/ ) { //Get Catalog variables var emptyVariables = []; var readonlyVariables = []; var keys = []; var set = new GlideappVariablePoolQuestionSet (); set . setRequestID ( current . request_item ); //--if table is sc_task //set . setRequestID ( current . sys_id ); //--if table is RITM set . load (); var vs = set . getFlatQuestions (); var description = '' ; for ( var i = 0 ; i < vs . size (); i ++) { var sDisplVal = vs . get ( i ). getDisplayValue (). toString (); //var sLabel = vs.get(i).getLabel().toString(); var sField = vs . get ( i ). getName (). toString (); //gs.addInfoMessage(!gs.nil(sLabel) + ',' + (sDisplVal!='') + ',' + sLabel + ': ' + sDisplVal); if (

copy variables to task description

Potentially for use where tasks are generated outside of workflow: var grTask = new GlideRecord ( 'sc_task' ); if ( grTask . get ( 'number' , 'SCTASK0011254' )){ var keys = []; var set = new GlideappVariablePoolQuestionSet (); set . setRequestID ( grTask . request_item ); set . load (); var vs = set . getFlatQuestions (); var description = '' ; for ( var i = 0 ; i < vs . size (); i ++) { if ( vs . get ( i ). getLabel () != '' && vs . get ( i ). getDisplayValue () != '' && vs . get ( i ). getDisplayValue () != 'false' ) { description = description + vs . get ( i ). getLabel () + " : " + vs . get ( i ). getDisplayValue () + "\n" ; } } gs . print ( description ); }

Double asterisk on dependent fields

Image
 displays the list

Dynamically update checkbox variable's label - classic UI and portal

var sMsg = "A checkbox message" ; if ( typeof spModal != 'undefined' ) { //--loaded from Service Portal g_form . setLabelOf ( 'attachment_attached' , sMsg ); } else { variableSysID = 'ad87f965db6f1c1011eaa0214b9619c4' ; //--the actual sys id of the variable itself var checkboxvar = document . getElementById ( 'ni.IO:' + variableSysID + '_label' ); checkboxvar . innerHTML = sMsg ;   }   from the HTML (inspect element): <div id = "variable_IO:8da14aa1dbaf1c1011eaa0214b96190c" class = "form-group sc-row " ><fieldset> <input type = "HIDDEN" name = "sys_original.IO:8da14aa1dbaf1c1011eaa0214b96190c" id = "sys_original.IO:8da14aa1dbaf1c1011eaa0214b96190c" container_id = "4da14aa1dbaf1c1011eaa0214b96190c" class = "cat_item_option" ><div cla