Skip navigation

Developer Community

2 Posts authored by: Ivan Garay Employee

Our platform makes difficult tasks easy. This simplification ServiceNow provides their customers effects how the customer developer thinks. They forget that programming is really not an easy task, and begin scripting without restraint. Developers must be strict on themselves: always testing, always checking, especially working in any platform that they did not create. Developers must ensure their customization coincides with the ServiceNow platform as one.


How an engineer customizes a ServiceNow instance relates to how many issues their company will have during business hours. Good customizations do not disrupt, bad customizations cause nightmares.


If you are going to customize ServiceNow do it right! Many customization issues are a simple fix on the engineer's side: check the variables.


Checking your variables while developing

If you’re not sure why your program is broken, then you may want to start with checking your variables.  Overall, variable checks establish a safe place for you to start your customization safely.


Checking your data will ensure that you are more than 50% done.


Checking your code allows you to:

  • See concrete data
  • Alert yourself when something is wrong
  • Ensure that it is not your mistake
  • Move on the the real issues in your system that deserve time, like the logical aspects of it.


Before assuming things just work, you owe it to yourself, to ensure you are working with good data.  For example, a manager opens an incident, frustrated with ServiceNow because their their engineer claims the one week issue they are experiencing is a ServiceNow error.  The business suffers and loses valuable work time, the manager says this is something ServiceNow must fix.  A ServiceNow support engineer reviews the incident and in a few hours can find the issue. In this case, it is clearly a modification on the client side.


The customization error, "variable is undefined," means the engineer's variables were non-existent or not defined well and caused the system to stop rendering correctly. An error like this can delay a roll out of a product for one month. This could have been resolved early on if the developer took a moment to review their variables.


How To Check Variables Basics in Javascript

The basic variable culprits that could be messing with your customization:

  • Undefined
  • Null
  • "" (empty string)


You need to check for these elements, to ensure that they do not prevent your instance from working correctly.


For any variable element where "elem" is the variable.

if (elem === null)  //try this

if (typeof elem === "undefined") //try this
if(elem === "")  //try this


You should be running the above three checks on every variable in your software, scripts, and applications. You can put the above example in a function so you don't have to rewrite them.  Once in a function you can return anonymous functions to correctly handle the variable's error in a safe manner rather then breaking your interaction.


For example:

function isEmpty(elem){
    if (elem === null) {
        return function(){ alert("Is Null");};
    else if (typeof elem === "undefined"){
        return function(){alert(“IS UNDEFINED”);}
    else if(elem === ""){
        return function(){alert(“IS EMPTY STRING”);}
    alert(“NOT EMPTY”);    
//This would be more helpful if your anonymous functions found alterior methods to notify the user of the issue or just found an entirely different work
//around to the error


You can easily test this out in the developer console in Chrome, IE, or FireFox. You will see an error described by a red X.


For example:

developer console.jpg


Unchecked variables cause all sorts of funny stuff to happen.  Unchecked variables are usually hard to find and cause the working of a page to halt.  Many Customers assume variables are just there and work correctly all of the time. The assumption that something should just exist without question, is dangerous and can affect your company's bottom line.

You own your instance and your source code, so you know what goes on inside of it.


Want to save yourself some time and possible headache? Double check the data you are working with.

Coding, scripting,  and developing is a lot like the game Pitfall. In Pitfall it is jump over this, avoid that, skip to here and then you're safe! Until you realize that your code doesn't work because there is a mistake and it killed your entire application.


Then you're stuck, so when you have no where left to turn you call:


Your Friendly Support Engineer!




Now The Questions Begin, Be Prepared, Look Like a Pro


What is Considered a Customization?

A Configuration is anything that is not shipped with the baseline product, but can be added using Service Now deployed tools. An example of this would be a new client script, a new business rule, or a new UI Policy using the Glide Libraries. A Customization is an altered configuration that goes beyond the platform methods. An example of this would be a new client script, business rule, or UI Policy that uses anything except Glide Libraries. For more on configurations and customizations, see Ch-ch-ch-changes: customizations vs. configurations.


Customer Support is limited to Configuration assistance with...

Examples of Configurations that are supported:

  1. UI policy that does not have any code associated with it.  The UI Policy is strictly made with the conditions builder.
  2. A Client Script that is limited to Service Now provided objects like GlideRecord.



Customizati that Support cannot assist with...

Examples of Customizations that are not supported:

  1. UI Policy is not working, because it is buried under client scripts with JQuery and Java Script not using the Glide Libraries.
  2. A Client Script that uses GlideRecord, and also has JavaScript, JQuery, Angular within it.



Support loves to help customers because it’s rewarding and fun to see customers excited about getting something done right.  Unfortunately, Support is limited to non-Customization incidents only. ServiceNow support is always looking for opportunities to help the customer set themselves up for success and with that we share our latest content on social media to help spread the reach of solutions, workarounds and best practices we put together.


I am hoping by outlining some of the things that ServiceNow support can and cannot do will help you...

  1. Find issues effectively.
  2. Ask better directed questions to support to get over the Customization HUMP.
  3. Get the support you need.


Over time I started noticing little things that customers CAN do to help themselves to avoid coding pitfalls. I will be sharing blog posts on coding best practices, to help you understand customizations and configurations a bit better so that support can work with you when things start getting dodgy.


Filter Blog

By date: By tag: