Showing posts from March, 2021

UI16 Developer Patch!/share/contents/9650888_ui16_developer_patch?v=2.5&t=PRODUCT_DETAILS

Determine ServiceNow Subscriptions/Licenses in the prod instance

 Note: possible on the production instance only as this info is not copied down to lower environments during a clone see  Subscription Management | ServiceNow Docs

get a field value in the glideAggregate

Must include a groupby clause in order for the getValue (or getDisplayValue() on a reference field) to work var REQsysid = '3eac6cbddb75a81081fb49a23996xxxx' ; var agg = new GlideAggregate ( 'sc_req_item' ); agg . addQuery ( 'request' , REQsysid ); agg . addAggregate ( "COUNT" ); agg . groupBy ( 'short_description' ); agg . query (); var answer = 0 ; while ( agg . next ()) { gs . print ( agg . getAggregate ( "COUNT" )); gs . print ( 'SD:' + agg . short_description . getValue () ); }

GetRowCount() versus GlideAggregate

 GetRowCount is not best practice, instead use GlideAggregate see  getrowcount example: var agg = new GlideAggregate ( 'sc_req_item' ); agg . addQuery ( 'request' , '3eac6cbddb75a81081fb49a2399xxxxx' ); agg . addAggregate ( "COUNT" ); agg . query (); if ( agg . next ()) { var answer = agg . getAggregate ( "COUNT" ); gs . print ( answer ); }

Write to script processing table (extended from DL) to execute stored gliderecord scripts

write gliderecord script to a table which can then be executed on a schedule using  GlideScopedEvaluator () -business rules to trigger the update action -script include to store entries in a scheduled script table (extended from DL so as to be outside of license cost) -scheduled job to iterate through the scheduled script table and execute rows ready to be processed CODE : new table extended from DL table (as per  Create custom data lookups ( Business rules - just examples REQ/RITM : after insert BR on REQ table, better solution would be a timer on the RITM workflow with the code in there, but this is an alternate solution if the workflow couldn't be updated for whatever reason. The challenge was picking up how many RITMs present on the REQ within the insert action end to end, which proved difficult using business rules alone ( function executeRule ( current , previous /*null when async*/ ) { //--REQ short description auto populated from linked RITM,