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
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 ( newValue == '' ) {         g_form . setValue ( 'item_request_type' , '' );          g_form . setValue ( 'item_catalogue_uid' , '' );         return ;     }       g_form . setValue ( 'item_request_type' , newValue );   }   Result on the form :refresh the catalogue UID  

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 (); }

Business rule: insert or update operation?

 current.operation() == "insert";  current.operation() == "update";

Service Catalog quantity pick list

 https://docs.servicenow.com/bundle/newyork-it-service-management/page/product/service-catalog-management/task/t_ItemQuantity.html

sys property to check if instance is prod instance

 can be set to "false" in sub-prod instances glide . installation . production