Skip to main content

Posts

Showing posts from October, 2021

ServiceNow Create a general request button on agent workspace to take users to a general request item

  script : function onClick () { var params = {}; params . sysparm_parent_table = "interaction" ; params . sysparm_parent_sys_id = g_form . getUniqueValue (); //params.sysparm_software_requirements = current.short_descritpion; var paramsJSON = JSON . stringify ( params ); var request = new GlideAjax ( 'RequestLinkSessionManager' ); request . addParam ( 'sysparm_name' , 'setComponentSessionValueMapJSON' ); request . addParam ( 'workspace_request_session_data' , paramsJSON ); request . getXMLAnswer ( function ( answer ){ onSubmitAfterSessionPut ( params ); }); } function onSubmitAfterSessionPut ( params ) { var result = g_form . submit ( 'sysverb

ServiceNow Service Request - Cart API / generate request programmatically (sn_sc.CartJS() ) - RITM

ServiceNow Service Request - Cart API / generate request programmatically (sn_sc.CartJS() ) - RITM see the docs https://developer.servicenow.com/dev.do#!/reference/api/vancouver/server/sn_sc-namespace/c_CartJSScoped var cart = new sn_sc . CartJS (); var item = { 'sysparm_id' : '0d08837237153000158bbfc8bcbe5d02' , 'sysparm_quantity' : '1' , 'variables' :{ 'carrier' : 'at_and_t_mobility' , 'data_plan' : '500MB' , 'duration' : 'eighteen_months' , 'color' : 'slate' , 'storage' : 'sixtyfour' }}; //var cartDetails = cart . addToCart ( item );   var cartDetails = cart . orderNow ( item ); gs . info ( JSON . stringify ( cartDetails )); //-- in case of errors, this will throw the error: gs.print(JSON.stringify(cartDetails));     try also the submitOrder() and orderNow() functions  or this format: gs . include ( 'Cart' ); var cart = new

ServiceNow Background script to identify all empty CMDB tables

var gr = new GlideRecord ( 'sys_db_object' ); gr . addEncodedQuery ( 'nameSTARTSWITHcmdb' ); gr . query (); var count = 0 ; while ( gr . next ()) { var cgr = new GlideAggregate ( gr . name ); cgr . addAggregate ( 'COUNT' ); cgr . query (); while ( cgr . next ()){ count = cgr . getAggregate ( 'COUNT' ); if ( count == 0 ) gs . print ( 'Name: ' + gr . name + ' Records: ' + count ); } }

ServiceNow Event Management: alter the run remediation options that appear under Quick Responses

     to get your custom sub-flow to appear under the run remediation box, go to the following alert management rule:      then go into the actions tab, scroll down to the remediation subflows list and replace the OOTB with your custom flow, ensure the execution is set to 'manual' or 'both' - usually both if automated alerts are to be created