- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 07-28-2021 04:55 PM
Everyone, in the Pattern Designer, when working on a step that creates Scalar or Tabular Temporary Variables, beware - if you accidentally incorporate leading spaces on your variable names you will have a hard time spotting the error and it will interfere with your attempts to make references to that Temporary Variable in Scripts (because you won't "see" the leading space, leading you to leave it out of your variable reference).
For me this error occurred because I was trying to be careful and precise with my variable names by copying and pasting names, from another source (a MIB file), into the definition of Scalar and Tabular variable definitions in Pattern Steps. This copy and paste function incorporated a leading space without me noticing.
This error resulted in JavaScript failing to obtain values from Temporary Variables, either when using the ${NAME} notation, or when using the context method CTX.getAttribute("NAME"). This presented itself to me as objects in my Scripts having NULL values, when I could plainly see that the Temporary Variables, which were used to fill my objects with values, were not themselves NULL. The difference of one space, in a variable name, was the cause of not passing values.
I do not know if leading spaces in variable names are possible elsewhere in the Service Now platform, but beware - if you are working with EVAL() scripts, or Custom Operations, in the Pattern Designer, and if you are repeatedly getting NULL values, where you expect non-NULL values, check any Temporary Variable definitions, in the Pattern, which your EVAL() script or Customer Operation might be referencing to populate objects with values, through ${NAME} notation or the context method CTX.getAttribute("NAME"). (I do not know if this could also occur because of trailing spaces in variable names, but that is also worth checking, if you're repeatedly seeing NULL values returned when you expect a non-NULL value.)