Skip to main content

Posts

Showing posts from August, 2018

ServiceNow PERSPECTIUM: workflows not triggering dynamic shares

Managed to get round this by introducing a timer + worknotes update in the workflow in this example in the RITM workflow, the sc_task is supposed to trigger the dynamic share

ServiceNow Perspectium: prevent circular updates

 “interactive=true” is an option, but bear in mind this  will prevent any non interactive updates from sending across the system (also any update from other integrations). Instead,  use below piece of code in your onbefore transform script to prevent bounce back issues:- if(action=='update'){                                                      target.psp_subscribed_record = true; }

Loop through RITM variables (variable labels)

var grRequestedItem = new GlideRecord ( 'sc_req_item' ); grRequestedItem . addQuery ( 'number' , 'RITM0016916' ); grRequestedItem . query (); while ( grRequestedItem . next ()) {   gs . addInfoMessage ( 'Variables for ' + grRequestedItem . getDisplayValue ());   for ( var prop in grRequestedItem . variables ) {     if ( grRequestedItem . variables . hasOwnProperty ( prop ) ){      var variable =   grRequestedItem . variables [ prop ]. getDisplayValue ();      var v = grRequestedItem . variables [ prop ];          if ( v . getGlideObject (). getQuestion (). getLabel () != '' ) {              var label = v . getGlideObject (). getQuestion (). getLabel ();                  gs . print ( label + ': ' + variable );           }            }   } } output: [0:00:00.050] Script completed in scope global: script Background message, type:info, message: Variables for RITM001691

Loop through RITM variables (variable names)

(courtesy of Community ) var grRequestedItem = new GlideRecord ( 'sc_req_item' ); grRequestedItem . addQuery ( 'number' , 'RITM0016916' ); grRequestedItem . query (); while ( grRequestedItem . next ()) {   gs . addInfoMessage ( 'Variables for ' + grRequestedItem . getDisplayValue ());   for ( var prop in grRequestedItem . variables ) {     if ( grRequestedItem . variables . hasOwnProperty ( prop ) ){      var variable =   grRequestedItem . variables [ prop ]. getDisplayValue ();       gs . print ( prop + ': ' + variable );     }   } } output: Background message, type:info, message: Variables for RITM0016916 *** Script: requester: R Smith *** Script: requested_for: R Smith *** Script: line_manager: Martyn *** Script: fj_server: BI01DW8BI001 *** Script: fj_type_access: privileged access *** Script: fj_details: sd *** Script: fj_access_from: 15/08/2018 *** Script: fj_access_to: 22/08/2018

Date vetting: start/end dates not in past, start date must be <=end date

onchange catalog client script code : start date 'access_from' variable : function onChange ( control , oldValue , newValue , isLoading ) {     if ( isLoading || newValue == '' ) {         return ;     }     var ga = new GlideAjax ( 'servicerequest_ajax' );     ga . addParam ( 'sysparm_name' , 'validate_fromto_dates' );     ga . addParam ( 'sysparm_startdate' , newValue );     ga . addParam ( 'sysparm_date_entered' , newValue );     ga . addParam ( 'sysparm_enddate' , g_form . getValue ( 'access_to' ));     ga . getXMLAnswer ( function ( answer ) {         //alert(answer);         var res = answer . split ( ':' );                 if ( res [ 1 ]!= "OK" ){             alert ( 'Check dates--' + res [ 1 ]);             g_form . setValue ( 'access_from' , '' );             return false ;         }     });     }