Skip to main content

Posts

Showing posts from February, 2018

Order guide: make it service portal friendly

Catalog client scripts ensure that the UI type is set to 'all' or 'mobile / service portal', I have noted that on an order guide 'all' did not always work in the service portal but I got round this by creating 2 copies of the same script, one with UI type set to 'desktop' and the other to 'mobile / service portal'

Hide the delivery time on catalog items / order guide

Hide the delivery time on catalog items / order guide   workflow properties of the catalog item: schedule > set expected times to zero

ServiceNow Hide/show related list on form

Hide/show related list on form   locate the related list ID under 'system UI > related lists' then use script as below: show: function  onCondition ()   {         g_form . showRelatedList ( 'u_task_vendors.u_task' ); } hide: function  onCondition ()   {         g_form . hideRelatedList ( 'u_task_vendors.u_task' ); } (ServiceNow)

ServiceNow workflow: Wait for all approval blocks to approve before proceeding

ServiceNow workflow: Wait for all approval blocks to approve before proceeding   Use a 'join' block in the workflow Example:

AJAX call example 1: return multiple values

AJAX call example 1: return multiple values Client script code: //--author: RDS Feb 2018 function  onChange ( control ,  oldValue ,  newValue ,  isLoading )   {      if   ( isLoading  ||  newValue  ==   '' )   {          // return;      }      //--default the line manager and job title from requested for field     g_form . setValue ( 'job_title' ,   '' );     g_form . setValue ( 'line_manager' ,   '' );      if   ( newValue != '' ){          var  ga  =   new  GlideAjax ( 'my_ajax_funcs_sc' );         ga . addParam ( 'sysparm_name' ,   'm_getuserinfo' );         ga . addParam ( 'sysparm_users...

ServiceNow Access the active flag from a client side script (g_scratchpad)

ServiceNow Access the active flag from a client side script ( g_scratchpad)   Display business rule: ( function executeRule ( current , previous /*null when async*/ ) {     // --RDS Feb2018 chg enhancements     //-- set scratchpad(s) which can then be used in client scripting/UI Policy scripts     g_scratchpad . chg_active = current . active ; })( current , previous ); Client script: alert ( g_scratchpad . chg_active ); //--seems to save scratchpad as a string, hence use: if ( g_scratchpad . chg_active == 'true' ){ }

ServiceNow: modifying field hint

Note: this is an older post, DOM manipulation is not recommended in ServiceNow --- options: use annotation via configure form layout > * annotations use g_form.showFieldMsg > use 4th boolean parameter and set to false to stop the form auto-scrolling to the field use g_form.addDecoration here's a rather clunky way of editing the change_request.test_plan hint: var el = gel("label.change_request.test_plan"); //var el = gel("status.change_request.test_plan"); alert (el.innerHTML); document.getElementById('status.change_request.test_plan').setAttribute('title', 'BLAHBLAH'); document.getElementById('status.change_request.test_plan').setAttribute('aria-label', 'BLAHBLAH'); alert(el.innerHTML);  var elements = el.getElementsByTagName('span'); alert('LEN: ' + elements.length); for(var i = 0; i < elements.length; i ++) {         if(elements[i].className === 'label-text...