Posts

Showing posts from 2023

Count Number of Days

SI Function:  daysToDueDate: function(incident) {          var totalDuration;           var now = new GlideDateTime().getLocalDate();       if (!incident.dueDate.nil()) {               var dueDate = new GlideDateTime(incident.duedate).getDate();               totalDuration = new GlideDateTime.subtract(now, dueDate);               var numberofDays = parseInt(totalDuration.getNumericValue() / 86400000);               }     return nubmerOfDays; },                                             

How to Get a list field values as comma seperated

SI Function:   inAListFied: function(incident) {     var userID = gs.getUserID();     var watchList = incident.getValue('watchlist');     if (watchList) {          var arrIncident = watchList.split(",");          var ListValues = (arrIncident.indexOf(userID) >= 0);       }     return ListValues; },

Core Concepts of Inbound REST API

Use the REST API Explorer to create and test inbound ServiceNow API requests. Path parameters are part of the endpoint URL.  Query parameters determine which records, which data, and the data format returned in the response body. The HTTP status code indicates the status of the transaction request and does not indicate any information about the returned data. The response body format is set in the headers. The REST API Explorer tests requests as the currently logged in user. The  Allow access to this table via web services  option cannot be tested in the REST API Explorer. Do not use the admin user in code integrations, create a web services only user instead. Disable web service access to tables with sensitive data unless web service access is required CORS rules add security to APIs CORS rules determine which cross-origin resources can access which methods.  CORS rules cannot be tested in the REST API Explorer.  Code samples provide script stubs for integratin...

Client Script - Why GlideAjax(with getXMLAnswer) ?

Image
The table is a good visualization of Simplicity versus Efficiency. API Simplicity Efficiency Description GlideRecord getReference 1st 5th - 1 line of code - Poor UX (blocks browser) - Returns entire record  GlideRecord 2nd 4rd - ~ 5 lines of code - Poor UX (blocks browser) - Returns entire record GlideRecord getReference (with callback) 3rd 3rd - 5-10 lines of code (with callback) - Best UX (does not block browser) - Returns entire record GlideRecord (with callback) 4th 2nd - ~ 10 lines of code (with callback) - Best UX (does not block browser) - Returns entire record GlideAjax 5th 1st - ~20 lines of code (Client Script + Script Include) - Best UX (does not block browser) - Returns only the data you need Note: Actually I would change "GlideAjax" into "GlideAjax (with getXMLAnswer)". GlideAjax with getXML still would return a whole document. While GlideAjax with getXMLAnswer would only return the exact answer you need. Read about this in one of my previous articles G...

LDAP Integration

  An LDAP integration allows your instance to use your existing LDAP server as the main source of user data. STEP1: Define LDAP Server Option1: LDAP Server with MID Server This is the most common method as it is the easiest to configure and doesn’t require much effort from a company AD admin. You’ll need to setup a  midserver  to use this method. Please note that you can’t authenticate (login) using this method and you can’t use a SSL connection. For authentication, an  SSO connection  is often configured. So you use the LDAP Integration to pull in users/groups and SSO to authenticate (login). Option2: LDAP Server with VPN For this method, you need to ask ServiceNow for a VPN Request though HI Support. This method isn’t that preferred is that you are relying on the ServiceNow VPN to work and other maintenance concerns. Option3: External IP Address For this method, you expose an external IP Address to ServiceNow. Option4: LDAPS with PKI Certificate Most companies...