Understanding Attachments in ServiceNow

This article was originally written in February 2016, but was last updated on 4/21/19.

Attachments in ServiceNow are not as straight-forward as email attachments, and it's not always obvious how to do what you want with them.

Recently, I needed to copy some attachments programmatically and otherwise fiddle around with attachments. After finding nothing in the ServiceNow product documentation, and very little through the usual search channels, I figured it was time to write an article about how to programmatically deal with attachments in ServiceNow. 

In this article, we'll learn how attachments really work in ServiceNow, how we can manipulate, copy, and even generate hashes for them (sometimes)! 

Read More

Using Custom Search Engines in Chrome to Quickly Navigate ServiceNow

How often have you wanted to do something like look up a record in a table by sys_id, look up a user by user_name, or jump straight to a table in ServiceNow just so you can run a query on it, but found yourself having to wait for the entire table to load, or having to navigate through several pages, waiting for each to load before you can get to the next?
For me, the answer is “multiple times, every single day”.

To that end, I’ve made this video on how to use custom Google Chrome search engines to make this process incredibly simple! Below the video, you’ll find some examples of useful “custom search engines” I’ve used in Chrome.

Click “Read more” to see the video, and some examples of how you can use this functionality!

Read More

Set Catalog Variables from URL Params (Free tool)

I've had this question come up over and over again in my career: "How do we populate variables on a catalog item or record producer, from the URL?" 

There are a couple of ways to do this, but often you'll see one-off solutions that require custom code for each and every catalog item, which also means that you have to know in advance, when designing the catalog item, what variables might be specified by URL, and how to populate them. 

I got tired of re-engineering the same basic solution over and over again, so I built a generalized tool. This tool adds to your system, a Variable Set. This variable set contains a catalog client script, but no actual variables (this is expected). The variable set is called “Parse sysparm_variables URI param”.

Once you’ve added the variable set to a given catalog item, you can populate any one or more variables in that catalog item, simply by manipulating the URL. Read on to learn more, or click here to jump straight to the tool/download page!

Read More

Outlook for Android Breaks Email Approvals (+Solution)

If you’re an Android user who uses Outlook (and who among us corporate tools is not blighted by that app on a daily basis?) you may have noticed that the Outlook app for Android has recently undergone something of a redesign recently.
I haven’t decided if I love or hate the new design personally, but however you may feel about it, it seems that they’ve done a bit more than just change the aesthetic.

That’s right, despite the fact that it’s been an IETF standard since July 1998 (see: RFC 2368), Microsoft just plum-forgot about one of the most basic functions of an email application - correctly processing mailto: links - and have now verified that this is a confirmed “feature limitation”. They “might consider adding this feature” in future updates, but for now, well, who needs standards, anyway?

Now hold on, because I can hear you saying:
“But Tim, you big dumb jerk with great hair, this is a ServiceNow development blog! Surely ranting about Microsoft is a bit silly here, isn’t it?”
And normally, yes, this would be merely a petty rant - one of my favorite kinds of rants -but in this case, the implications of this are important for us ServiceNow nerds.

Thanks to Nick Simonelli (ServiceNow developer at Chipotle - lucky jerk) for bringing this to my attention in the ServiceNow Slack community!

Read on to learn more (and see the solution)!

Read More

GlideFilter is Broken - Free Tool: “BetterGlideFilter”

Once upon a time, there was a global, instantiatable “GlideFilter” object. It was a little ugly and unintuitive, but it technically worked; usually. Nowadays though, the GlideFilter object is a scoped-API object (also available to the global scope) that is not instantiatable, and which has… some problems.
ServiceNow is aware of these problems, but - although they continue to use GlideFilter in their scoped apps (such as for vulnerability grouping rules in the Vulnerability application, which have been broken by the use of GlideFilter as of London - PRB1329737) - they have refused to fix the issues (PRB605673).

“What problems”, you ask? - Read on, to find out, and to see the solution/free tool!

Read More

Making Update Sets Smarter - Free Tool

Update Sets are how you track and promote changes to your ServiceNow environment from one instance to another (for example, from Dev to Test, and then from Test to Prod). They’re a great tool for keeping things orderly, but they don’t always tie up into a neat little bow when you need them to - especially ever since the implementation of Application Scope, on which you can see my angry ramblings here.

If you work with scoped apps (such as the HR or Vulnerability apps, or a myriad of others), you’ve almost certainly run into custom development being done in a scoped Update Set, but somehow containing Global (or non-scoped, which are basically the same as Global) records, and you’ve undoubtedly seen the dreaded error message, telling you that you can’t deploy an Update Set because it has updates from multiple scopes.

Or maybe you’ve built a Workflow in dev, checked it out, made some changes, published it, checked it out again, made some more changes, and then promoted it… but then - D’OH! - you realize you forgot to check the workflow back in before promoting your Update Set!

Or maybe you’re in an environment that has a few super green ServiceNow developers, or at a company that’s extremely liberal with granting the admin role, and you’ve had to clean up the mess after someone else renames or deletes the “Default” Update Set in Global or some other scope.

In my years as a ServiceNow admin, developer, and architect, I’ve seen all of those issues, and in each case, I’ve written a little script to save a little sanity, and make my life just a little bit easier by preventing these issues; and in this article, I’m going to share them with you.

Click below to read on!

Read More

How to Learn ServiceNow

Hi! I'm Tim Woodruff. I write most of the articles SN Pro Tips articles, and I’m the author of a few books on ServiceNow development, including Learning ServiceNow, and The ServiceNow Development Handbook. I've put together this quick-start guide to learning ServiceNow development, to give you a quick intro to the things that I personally think are important to know, when beginning a career as a ServiceNow developer.

This article is not meant to actually teach you to be a ServiceNow developer (it’s far too short for that). Instead, it's meant to be something you can reference when you feel like "Okay, what next?" on your journey to becoming an excellent ServiceNow developer. 

Read More

ServiceNow & ITSM as a Career?

Starting a career within a new IT niche can be risky, but the potential rewards can be outstanding.
Maybe you're just starting out your career in IT Service Management development/administration/architecture, or maybe you're a veteran of the industry and you're looking for a change. Either way, in this article, we're going to discuss ServiceNow, ITSM, ITBM, and ITOM as a career-path. We’re going to discuss:

  1. Some things you should consider when deciding on your career path

  2. Modules and specializations that are in high demand right now

  3. Building an ITSM-centric resume, and what to focus on

  4. ServiceNow certifications

  5. Interview Pro-Tips

  6. How to break into the industry without experience

  7. Salary negotiation and expectations

ServiceNow admins, developers, and architects are in extraordinary demand, due in large part to the fact that ServiceNow is the fastest growing IT platform in the market, with almost triple the share of its competitors. This, and the ludicrous speed with which ServiceNow has obtained this market-share, has resulted in a strong demand for ServiceNow technical experts.

Whether you're looking to begin your ServiceNow/ITSM, ITBM or ITOM career, or you're already an ITSM veteran just looking for a change, we've partnered with Michael Green, VP of Nelson Frank (one of the few staffing and recruitment firms that I personally trust), to put together some handy interview and resume tips to help you climb the career ladder.

Note: This article is a collaboration. It was not sponsored or paid for in any way.

Read More

Asynchronous onSubmit Catalog/Client Scripts in ServiceNow

I often get questions that go something like this:

When a user submits a Catalog Item, I need to be able to do some validation that requires client-server communication (either a GlideAjax script, a GlideRecord query, or a getRefRecord() query). How can I make this happen?

As anyone who’s read my article on requiring attachments in the Service Portal knows, ServiceNow has been (for better or worse) making some changes to how you are supposed to, and able to, do certain things within the platform. What’s relevant to this question, is that ServiceNow does not allow synchronous client-server communication in the portal; which means that your catalog client scripts should not use synchronous versions of GlideAjax, GlideRecord, or getRefRecord().
This is fine, and generally good advice anyway. Synchronous client-server operations lock up the user’s browser, and typically make for a poor user-experience. However - onSubmit Client and Catalog Client Scripts need to run synchronously, because if they don’t return false, the form will submit, reload, and stop any scripts that are currently running (or waiting to run; such as your callback function).

Click “Read more” below, to see the solution!

Read More

How to do Massive, Slow Database Operations Efficiently With Event-Driven Recursion

Scenario: You need to perform a very heavy scripted database operation, on a very large number of times.

To do this all at once, would: (1) slow down your instance, and (2) take longer than the maximum allowable transaction time/sql count/etc. and (3) other bad stuff.
Each operation takes between 10 and 60 seconds because of the additional business logic that needs to run.
You can't optimize the operations, they're simply slow, and there's a lot of them.

Example: You need to reclassify 100,000 CIs from one class to another (a very heavy operation on a large number of records).
How do you handle this?

I’ve run into this scenario a lot, and in every team I’ve been on (which is a fair number), the go-to answer, is to run a scheduled script which does the operation on a batch (some specific number) of records at a certain interval.

But imagine if you have the job run every 10 minutes, and it deletes 20 records per run.
You can imagine a scenario where the instance or scheduled job is particularly slow due to uncontrollable circumstances (such as the volume of integrations hitting the instance at that particular moment, or a discovery run happening simultaneously with the scheduled script). In this case, the job could take some amount of time longer than the average interval between jobs, in which case the jobs would begin to "pile up" and result in a sort of traffic jam that would both be inefficient, and be a massive drain on instance performance.

So the way to do this safely, would be to figure out what is the longest amount of time you could imagine one "batch" taking, and then setting the scheduled job interval to a little bit more than that amount of time multiplied by the number of records per batch. For example, if you do a 20-record batch and each record takes takes between 10 and 60 seconds, you might want to run one batch every 12 or so minutes.

However, if you need to update 100k records at a rate of 1 every 1.2 minutes, that is 120,000 minutes, or 83 days (24 hours per day).

So, for an operation like this, how can we make it the most efficient that it can be, without bogging down our instance?
The solution: Event-driven recursion.

Using a scheduled job with a gap between each job prevents the “pile-up” effect, which is good, and it gives anything else which might be piling up in the queue (such as a discovery run) to have some time to run. But, since each job might take a different amount of time, we have to be overly conservative with our intervals.
However, with event-driven recursion, we can set it up so that each batch triggers the next! This would prevent the pile-up, and send the next batch to the “back of the line” in terms of the scheduling queue. The result would be that the batches would run slower when the instance is busy, but much quicker when the queue is empty, preventing the pile-up effect, and preventing bogging down the instance, both without sacrificing much in terms of the performance of our actual operations (which we’d like to get done before Jules Verne’s round-the-world journey finishes).

Continued in the full article below…

Read More