Posts

Showing posts from January, 2021

Import a sample of prod tickets into test - request

import the xmls, in this order:  sc_request sc_req_item sysapproval_approver sc_task wf_context wf_executing wf_history wf_transition_history

what is GwtMessage???

 https://community.servicenow.com/community?id=community_question&sys_id=e2715f2ddbdcdbc01dcaf3231f961978

get ALL fields changed and pass these to a queued event

var gru = GlideScriptRecordUtil . get ( current ); var fields = gru . getChangedFieldNames (); //Get changed fields with database names //Convert to JavaScript Array gs . include ( 'j2js' ); fields = j2js ( fields );   gs . eventQueue ( "<an_event>" , current , fields , gs . getUser (). getEmail ());  

Transform map: bulk update groups and group memberships

Image
- drop the current group members - repopulate the group members - update the group (e.g. group manager) import sheet format: , delimited list of users (email) transform map scripts //--prevent insert onstart : var grGrps = new GlideRecord ( 'sys_user_group' ); grGrps . query (); log . info ( 'onStart:TrMap:BulkUpdateCCGrps:: sys_user_group count= ' + grGrps . getRowCount ()); var grGrpMems = new GlideRecord ( 'sys_user_grmember' ); grGrpMems . query (); log . info ( 'onStart:TrMap:BulkUpdateCCGrps:: sys_user_grmember= ' + grGrpMems . getRowCount ()); oncomplete : //--record the final counts var IS = source . sys_import_set . getDisplayValue (); var grGrps = new GlideRecord ( 'sys_user_group' ); grGrps . query (); log . info ( IS + ' - onComplete:TrMap:BulkUpdateCCGrps:: sys_user_group count= ' + grGrps . getRowCount ()); var grGrpMems = new GlideRecord ( &#

Javascript: format number to 2 decimal places

  var iNum = 190.1 ; gs . print ( iNum . toFixed ( 2 ));

syntax for service catalog lookup select: pull cat item sys id into reference qualifier

  javascript : 'active=true^u_catalogue_item='   +   current . cat_item . sys_id ;

service catalog lookup select: pull cat item sys id into reference qualifier, use data lookup definitions

Image
Service catalog dl: https://docs.servicenow.com/bundle/orlando-it-service-management/page/product/service-catalog-management/concept/c_ServiceCatalogDataLookup.html   extending system dl table so as not to incur license cost: https://docs.servicenow.com/bundle/paris-platform-administration/page/administer/field-administration/reference/r_CreateCustomDataLookups.html this variable does a lookup to a table extending the DL tables to perform a data lookup to pull in a value named “catalogue UID” based on the “request type” variable: Data lookup table (extends DL table) variable javascript : 'active=true^u_catalogue_item=' + current . cat_item . sys_id ;   Corresponding variables populated via data lookup definitions Catalog client script on the request type to populate item request type> which in turn fires the data lookup definition: function onChange ( control , oldValue , newValue , isLoading ) {   if ( isLoading ) {        // return;     }     if ( newVal

Push end user out of portal view: load a page and its widgets without the portal look at feel

 this is the format for any portal page+widgets, using sp.do. Case in point, surveys https://<instance>.service-now.com/ $sp.do ?id=take_survey&instance_id=83270d33db61e0101beb298a489619d6 other example, loads the page and widget outside of portal frame: https://<instance>.service-now.com/ $sp.do ?id=sc_category&sys_id=0ebdf489db07cf0046cc72dabf96xxxx

clearing all email logs in a sub prod instance

 discussed here: community --- var instURL = gs . getProperty ( 'glide.servlet.uri' ); if ( instURL . indexOf ( 'https://PRODINSTANCE.service-now.com' )>- 1 ) { gs . print ( 'do not run on prod' ); } else { var grEmails = new GlideRecord ( 'sys_email' ); grEmails . addQuery ( 'type' , 'send-ready' ); grEmails . setValue ( 'type' , 'send-ignored' ); grEmails . updateMultiple (); }