This article is part one of a multi-part series called "SN101", in which we'll explore some of the basic functionality of ServiceNow in beautiful detail. While the "SN101" articles are aimed toward newcomers to the ServiceNow platform, or new JavaScript developers, there is very likely to be something for everyone in each article. Thus, even if you are an experienced developer, it is recommended that you read the SN101 articles in chronological order.
Let's talk about building queries in ServiceNow...
See the whole article including some pretty awful puns, after the jump.
Read more
Dozens of times, I've seen hard-coded sys_ids in scripts or system properties, and wanted to know what record they correspond to. Unfortunately, there isn't really a good way to do this without knowing what table the sys_id is in!
The global search box only supports searching by sys_id on tables for which that is specifically enabled, so the only solution for this has often been to scour script after script, digging down until I find where the sys_id is actually used, and try to decipher what table it corresponds to. Well, today I decided - "Enough is enough" - and I wrote a script to check each table for me. I was surprised at the ease with which I was able to accomplish my goal, as well as the speed and simplicity of the script.
Read more
Let's say you're working for a company who has just acquired another company, and you've just imported all of the users from the acquired company's User (sys_user) table.
Unfortunately, you realize just a second too late, that their user database contains some of the same people as are already in your database - for example, some executives had accounts in both services.
Or maybe you were previously running the instance without enforcing number uniqueness on the incident table for some reason, and you want to change that.
The first step to resolving these issues, is detecting duplicate records, based on a given field. Here's a simple script include that will do that for you:
Read more
I'm baffled that this little issue has never cropped up for me until now, but I recently discovered a little annoyance in ServiceNow while iterating through an array. This issue had me going round in circles for hours, so hopefully by sharing my findings with our readers, I can spare some folks the frustration I felt.
First, I'll tell you a little story about how it happened to me, and then I'll tell you the explanation for this odd behavior.
Read more
I recently found myself in a situation where I had to check if a given record (the 'current' object in my case) matched a filter associated with another record (a client script, in my case). If you find yourself needing to do something similar, it might help you to know about an undocumented Glide API called "GlideFilter".
GlideFilter takes two arguments:
- A glide record containing the record you'd like to check
- The query string (aka "encoded query") you'd like to check it against.
The first argument may be self-explanatory - it's a GlideRecord object containing a single record.
The second argument, if you're not familiar with encoded queries, is a string of text that represents a query. If you've ever built a query in a condition builder, you've built an encoded query.
Read more
If you're a ServiceNow Admin, chances are you get lots of tickets from people asking you to grant or revoke access to this or that.
Sure, onboarding and offboarding, and some basic permissions work, can be automated -- but sometimes you just don't have a catalog item for what the user is requesting, so you have to do it manually.
sigh
So if you're like me, you get these tickets all the time:
"Jerry doesn't have access to the same applications as the rest of our team. Please add him to whatever groups he requires to do his job. Nerd."
Unless you're intimately familiar with Jerry's job, you're going to need some more information to go off of. I normally ask for the ID of another user whose access I can clone, and then open each profile on a separate monitor and go through each group one at a time. I once did 77 groups this way, for two separate users. It was a nightmare...
Read more