Skip to main content

Posts

Showing posts from September, 2018

Consuming a staging table endpoint & transform map using REST

whilst below works, developer site actually recommends the format: /api/now/import/<staging table_name> https://developer.servicenow.com/app.do#!/rest_api_doc?v=kingston&id=c_ImportSetAPI ------------------- web service endpoint created in a remote ServiceNow instance via system web services> create new, where the staging table name is  u_staging_table_xyz  and the requests are processed to the target table via a transform map SOAP wsdl to consume from another ServiceNow instance might be     https://<servicenowinstance>.service-now.com/u_staging_table_xyz.do?WSDL format for consuming this on REST would be:     https://<servicenowinstance>.service-now.com/ api/now/table/ u_staging_table_xyz   Example test harness for a POST operation  go to REST messages and create a new REST message as a test harness, and create a new http POST method: set up a basic authentication profile and configure the authentication profile to use as crede

Bit of code I was looking at

var gdtBST = new GlideDateTime (); var tz = Packages . java . util . TimeZone . getTimeZone ( "Europe\London" ); gdtBST . setTZ ( tz ); gdtBST . setDisplayValue ( current . getDisplayValue ( 'opened_at' )); var dT = gdtBST . toString (); var dateSection = dT . split ( ' ' )[ 0 ]; //Gets the Date var timeSection = dT . split ( ' ' )[ 1 ]; //Gets the Time current . u_call_log_date = dateSection ; current . u_call_log_time = timeSection ;

AJAX call example 2: return single value

AJAX call example 2: return single value Client script code: //--author: RDS Feb 2018 function  onChange ( control ,  oldValue ,  newValue ,  isLoading )   {      if   ( isLoading  ||  newValue  ==   '' )   {          // return;      }      var ga = new GlideAjax ( 'fj_servicerequest_ajax' );     ga . addParam ( 'sysparm_name' , 'refreshItemDescription' );     ga . addParam ( 'sysparm_req_type' , newValue );     ga . addParam ( 'sysparm_req_category' , g_form . getValue ( 'fj_request_category' ));     ga . addParam ( 'sysparm_req_subcategory' ,            g_form . getValue ( 'fj_request_subcategory' ));      ga . getXMLAnswer ( function ( answer ) {           //alert('AJAX return:' + answer);          g_form . setValue ( 'fj_request_shortdescription' , answer );      });      } } Script include script (client callable): var  my_ajax_funcs_sc  =

ServiceNow Perspectium: script an ignore condition in a dynamic share

enter the additional filter in the 'before share script' section of the outbound dynamic share:

Client scripting: disable options from a dropdown

(courtesy of ServiceNow Guru: https://www.servicenowguru.com/scripting/client-scripts-scripting/removing-disabling-choice-list-options/ ) //--remove the state options from the dropdown     var control = g_form . getControl ( 'state' );     var options = control . options ;     for ( var i = 0 ; i < options . length ; i ++) {         var option = options [ i ];         var ov = option . value ;                 if ( ov != '-24' ) {             control . options [ i ]. disabled = 'true' ;         }             }

ServiceNow Perspectium: work notes duplicates niggle

Scenario : a duplicate worknote ends up getting written whereby an extra update transaction from Perspectium containing the following in the xml is sent     <work_notes>_123 STREAMENTRY 321_original worknotes entered</work_notes> Not too sure how this has come about but the steps to create it were reproducible Create problem ticket in ServiceNow instance 1 and send to  ServiceNow instance 2 Wait until number returned to  ServiceNow instance 1 from ServiceNow instance 2 Go into  ServiceNow instance 2 Enter a comment, cick ‘post’, then immediately change the state to <some value>, click save fix: include some error trapping in a try>catch within the inbound transform map to ultimately set the row to ignore=true var iWN_err = source . u_work_notes . toUpperCase (). indexOf ( 'STREAMENTRY' ); if ( iWN_err >- 1 ){                         //--known error whereby the worknote has arrived as a duplicate jumbled string

Adding an attachment to an outbound notification

Adding an attachment to an outbound notification    updated ref: https://docs.servicenow.com/bundle/utah-platform-administration/page/administer/notification/concept/c_AttachingDocsToANotification.html ------ https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/administer/notification/concept/c_AttachingDocsToANotification.html notifications email script - uses interim integrations attachments table attachLinks (); function attachLinks () {     //Check if there are attachments to be sent     var intAttach = new GlideRecord ( 'u_task_integration_attachments' );     intAttach . addQuery ( 'u_task' , current . sys_id );     intAttach . addQuery ( 'u_vendor' , gs . getProperty ( 'zzzz.vendor.sys_id' ));     intAttach . addQuery ( 'u_send_attachment' , 'true' );     intAttach . query ();       if ( intAttach . hasNext ()) {       template . print ( "Attachments: <br