We have a new book!

Hey everyone! By way of explanation for the lull in posts lately, allow me to announce our latest book! The ServieNow Development Handbook is, as the subtitle says, a compendium of guidelines and best-practices for ServiceNow development and administration. It's a short (<100 pages) information-dense guide that I hope you'll find yourself returning to again and again.

The paperback is only $15 and the Kindle version is just ten bucks! Click here to learn more and get your copy.

In addition to The ServiceNow Handbook, I've also been finishing up the second edition of Learning ServiceNow, which is also nearly complete and we're aiming for a release date in the very near future! 

You can see all of our books on Amazon at this link

Requiring Attachments (& Other Miracles) in Service Portal

Unless you're somehow still rocking UI15 and do most of your development on a Commodore 64, there's a good chance that by now you're at least vaguely familiar with ServiceNow's new(-ish) Angularized end-user front-end feature: the Service Portal.

If you've tried to implement your Service catalog in the Service Portal, there's also a good chance that you've wept openly over your keyboard, trying to find an effective and non-hackey way to replicate functionality that was readily available using out-of-box APIs in the old Jelly-based CMS and catalog form. Stuff you'd think would be really basic, especially two full major releases later, it just not possible in the Service Portal. g_form APIs like getControl() and getElement() (and gel()) don't exist in Service Portal. Neither does any synchronous GlideRecord query or GlideAjax call, meaning that if you want to check something on the server in an onSubmit() script, you're out of luck. 

One of the biggest annoyances resulting from this, is that there is no good way to check if a catalog item has attachments as the user submits the form. This means that you cannot make attachments required on a specific catalog item.
Oh sure, there are sort of ways to do it, such as modifying the catalog item widget just for that catalog item, so that the client controller and server script work together to check for attachments. Or you could embed the whole CMS or ITIL UI catalog item form in an iframe. Unfortunately, both of those have major downsides. 

I've made this solution, in order to restore some basic functionality, with a mind toward the specific problem of checking for attachments in the Service Portal. 

Here is a basic feature-list of the below functionality: 

  1. Require attachments on submission, using sp_form.getAttachments()
    • Require attachments of a specific type
    • Require a specific number of attachments
    • Require a specific number of attachments of various types
  2. Access DOM element of variable field input box and div element, using sp_form.getElement() and sp_form.getControl()
  3. Access variable names, sys_ids, and question text, using sp_form.variables or sp_form.getVariables()
  4. Iterate over each variable on the page, or otherwise retrieve variable sys_IDs, names, and question text without having prior knowledge of each within your catalog client script. 

Click below to read on! 

Read More

Handling TimeZones in ServiceNow (TimeZoneUtil)

Dealing with Time Zones in ServiceNow can be a real nightmare. The only documented way to set the time-zone of a GlideDateTime object, is the setTZ() method. Unfortunately, this method requires a "TimeZone" object be passed in, in order to set the time-zone.

What is a TimeZone object? It's an object that doesn't exist in JavaScript, and the only way to get hold of one using the ServiceNow API is to use gs.getSession().getTimeZone(), which just gets the current user's time-zone. If you want to know what time it is in a different time zone though, you're out of luck, chump! 

At least, you were. Sufficiently annoyed by this problem, I finally decided to write a Script Include to handle this for me, and now that I've been using (and testing) it for a while now, I'm comfortable publishing it for general consumption.

Click below to read on, and get a copy for your own instance! 

Read More

How to Enable DOM Manipulation in ServiceNow Service Portal Catalog Client Scripts

ServiceNow has effectively prevented its customers from utilizing any form of DOM manipulation in the service portal. For those who were brave enough to invest heavily in the Service Portal early on, this has caused major issues.

Nearly every ServiceNow customer with an even moderately utilized Service Catalog, has some Catalog Client Scripts which make use of things like g_form.getElement(). Here are just a few things we've run into, that we're not able to do in Service Portal without MAJOR custom hacks:

  • Use the document object to retrieve URI parameters in order to parse them for a client script
  • Adds event listeners to input fields on load in order to monitor for events other than "change" which requires entering the field, modifying some data, then tabbing out of the field again. 
  • Parse URI parameters to do any kind of auto-population or other processing based on them, by using document.URL.parseQuery() (the solution recommended by ServiceNow).
  • Toggle form containers
  • Get information from fields in other widgets,
  • Redirect pages
  • Show/hide/change a variable label, variable set, or container dynamically

Click below, to keep reading and learn how to re-enable all of this functionality in your Catalog Client Scripts on the Service Portal. 

Read More

What's New in ServiceNow: Jakarta (Pt. 1)

I don't know about you guys, but having worked with ServiceNow since the pre-Fuji days, I can hardly believe how far the platform has come in just a few short years. 

If you've been following SN Pro Tips for a while, you may have seen our articles on Geneva and Helsinki. In that same spirit, today we're bringing you a break-down of what's new in ServiceNow's Jakarta release, and all the main points you'll need to know and keep an eye out for, as an Admin or developer. 
This has been another really significant update to ServiceNow, so we can't cover every little detail, but if we missed something that you think is important, please leave a comment and let us know your favorite new feature! 

Click below to read on, and learn what's new in ServiceNow Jakarta! 

Read More

Powerful Scripted Text Search in ServiceNow

If you've ever searched from the list view of a given table, you may have seen the "for text" option next to the search box in the list header.

This search box can be configured to directly search in any field which is displayed in the list view, but you can accomplish that just by clicking the "magnifying glass" icon to the left of the column headers. 

You might notice though, that this text search isn't.... very... good. For example, if you search for multiple words like "blackberry configuration", the search assumes that you want all of the words in the search to be included in any of the results returned, so results like "blackberry setup" would not be shown. 

Let's explore why, and see if there might be a better way to do this kind of text search in our scripts. 

In this article, we're going to learn about the differences between 123TEXTQUERY321, IR_AND_QUERY, IR_OR_QUERY, and - IR_AND_OR_QUERY, as well as how to use them in scripts! 

Read More

Work at Lightspeed: ServiceNow's Plan for World Domination

I'm excited to be participating in Knowledge17, learning about the transformational past and future of the ServiceNow platform. A software tool developed by a single individual, Fred Luddy, only fourteen years ago has grown into a comprehensive enterprise solution which topped a billion dollars in revenue last year, and plans to grow that stream to four billion dollars by 2020.

John Donahoe (Chairman of the Board at PayPal and former CEO at eBay) joined ServiceNow as their new CEO only 45 days ago, and today he demonstrated how a tool which was previously so IT-centric is evolving to facilitate amazing customer experiences across departments throughout any organization. He's helping drive that innovation by spending a great deal of his time listening to ServiceNow's customers and inviting them to collaborate with ServiceNow's team in strategic discussions. John's decision to invert ServiceNow's organizational chart, placing his square at the bottom, soundly illustrated his commitment to provide outstanding servant leadership.

The technological innovations we saw today transcend the traditional boundaries between HR, IT, Finance, Security, Compliance, Legal, Customer Service, and other 'siloed' business services. That seamless integration allows us to accomplish our work with dramatically improved efficiency. This is possible not solely because we have the information we need, but because we can aggregate, breakdown, visualize, and react to that enormous wealth of information in real time, and we are continuously improving the tools and processes we use to do so.

We also heard from Dr. Scott Mason, COO at Novartis and Ashley Haynes-Gaspar, VP at GE Digital about the revolutionary changes ServiceNow is enabling in their organizations. Scott and Ashley each bore witness to the reality of these benefits. For example, Ashley spoke about how she and her team selected ServiceNow to replace 95 legacy systems at GE Digital, allowing their people to share information and cooperate like never before. She predicted a savings of trillions of dollars over time.

Ashley also devoted a significant portion of her presentation to addressing the massive gender inequality we see in the technology industry, sharing the importance of enabling girls to begin developing technical mindsets from a young age. As a father, I am committed to ensuring that my daughter has even more opportunities for success than I've enjoyed, and it's personally inspiring to see the progress Ashley is driving in this area.

Dave Wright, Chief Strategy Officer at ServiceNow took the stage to give a truly mind-blowing presentation about the future of the platform, explaining how the advent of machine learning in the operations management space is going to streamline organizations in every industry in ways we can barely fathom today.

He demonstrated the power of this AI by coupling it with event management to detect precursors to upcoming problems. This allows us to proactively solve incidents before they even occur!

Whether it's medicine, power generation, sales, insurance, government, or anything else you can imagine, our ability to collaborate and innovate will increase exponentially as we learn to maximize the benefits we gain from technology. When that technology is coupled with inspiring leadership and cohesive teams, there's no limit to what we can accomplish together.

Source: https://www.linkedin.com/in/garrison-ball-...

Avoiding Pass-By-Reference Using getValue() & setValue()

Server-side GlideRecord objects contain an element for each field in the table that the record is in. These elements are not primitive values (strings, numbers, booleans), but Objects. The type of object is GlideElement, and the GlideElement API is available. However, since JavaScript is a "loosely typed" language, you can reassign a variable of one data-type (such as an Object) to another type (such as a string) without any hassle. Thus, setting a GlideRecord (gr) element's value to a string will overwrite the reference to the GlideElement object itself. This bad-practice example would look like:

gr.short_description = 'New short desc.';

Primitive values are stored on the stack, and are accessed directly by variable name. You might say that they are "contained within" a variable. A reference value on the other hand, is merely a pointer (or, you might say, a reference!) to an object which is stored on the heap. The difference between the heap and stack isn't important here, but it is important is that they're different. An object variable in JavaScript does not technically contain an object, but rather it contains a reference to that object. Consider what might print out, if we run the following in a background script:

var parent = {
prop1: 'val1'
var child = parent;
child.prop1 = 'new value';

In the above example, we declare an object: parent...

Read More

"Learning ServiceNow" is Now Available for Purchase!

We are pleased to announce that our new book, Learning ServiceNow, has been published and is available to purchase on Amazon, as well as on the publisher's website. Simply navigate to book.snguys.com to pick up a copy for yourself!

This book is geared toward new ServiceNow administrators and developers, who have less than a few years of experience managing the platform, but everyone should get something from it.
We take a ground-up approach in this book, and include advanced pro-tips along the way. We even have a whole section dedicated to things that expert developers wish they'd known when they were first starting out. There's something for everyone! 

All you need to know to get started, is basic JavaScript syntax, so head over to book.snguys.com and get your learn on! 

reCAPTCHA in ServiceNow CMS/Service Portal

There are a multitude of reasons that one might want to verify that the person submitting a form, is indeed a person, and not a robot. Perhaps you've got a public-facing CMS or portal page, or perhaps you just want to verify that users can't just script their way through auto-ordering loads of computers, especially if their accounts are compromised. 

Whatever the reason, if you need to verify that a form submitter is indeed a person and not a robot (AKA: "CAPTCHA"), read on to find out how, and even get a downloadable update set that you can deploy into your instance to enable this functionality straight away (with a few minor setup-config tweaks). Click "Read more" below, to see the full article and download link. 

Read More

Pro Tip: Use updateMultiple() for Maximum Efficiency!

Although most of our free time has been spent focusing on writing the Learning ServiceNow book, we wanted to post a quick Pro-Tip to address an issue we've seen impact performance on nearly every instance we've worked on: The use of loops to update a single field on a large number of records in the database. 

Let's say you've got a client who wants to run a scheduled job that'll auto-close Incidents in "In Progress" status, that haven't been updated for 30 days, by setting their state to a custom value, "stale" (or, since State is an integer field, 10). Let's see what a script for that purpose might look like, as it's usually written...

Click below to read more! 

Read More

We're Writing a Book!

You may have noticed that we haven't posted a whole lot in the last few weeks. This is because I (Tim Woodruff, Owner/Founder of SN Pro Tips & The SN Guys) write the majority of the articles that show up here, and I've been directing my writing efforts elsewhere recently... 

We're Writing a Book! 

That's right, in case the title of this post didn't ruin the surprise, we are writing a book on ServiceNow Development and Administration in partnership with Packt Publishing, which has just been announced. This book is called "Learning ServiceNow" (ISBN 9781785883323), and it is geared toward the zero-to-medium-experience ServiceNow developer, and is meant to serve as both a complete guide to getting started with ServiceNow development and administration, as well as a knowledge-boost for any newer developers (say, devs with less than a couple of years of experience). 

I also intend to include a "pocket reference" type of document with some of the best Pro Tips you'll find in the book, as well as from this site! 

I just wanted to make sure our readers don't get the idea that we're going anywhere since we haven't released an article in a while. Once this book is published, we'll have some great new content coming your way, including some features from the book if we can! In the meanwhile, we hope to post a few quick Pro Tips here and there, but we hope you'll subscribe to stay tuned for our bigger, deep-tech articles, several of which we've already got lined up on the back-burner, including: 

  • The best way to perform a query in a nested loop
  • Creating a unique/one-to-one relationship in ServiceNow
  • A debugging series, including:
    • How to debug field visibility/mandatory/read-only state
    • client-side, and server-side javascript errors. 

In the meanwhile, feel free to check out our archive to review some of our other articles. As always, don't hesitate to contact us if you have a question or want to discuss how we can help your business with any ServiceNow-related needs. Thanks for reading! 

SN Pro Tips is owned and written by The SN Guys, ServiceNow consultants. If your organization could benefit from our services, we humbly welcome you to schedule some time to chat and share your goals with us, so we can help your business Grow With Purpose

Chrome Extension: Load in ServiceNow Frame

Over a year ago, when I first launched this website, I posted some free versions of my earliest tools. One of the first little tools I posted, was the SN Frame bookmarklet. As with all tools on this site, we put it out there for free and without any advertising or other nasty stuff. Today, we've just released the latest version of this tool as a Google Chrome Extension. Read on for more info, or click that link to download the tool from the Chrome extension store. Alternatively, you can search for SN Framerizer on the Chrome extension store

I often find myself middle-clicking a link or otherwise opening links in ServiceNow in a "new tab" or "new window". This means that I often get pages that load just the content frame, without the ServiceNow frame...

Click below to read more! 

Read More

Force-Include Any Record Into an Update Set

While most of the records in ServiceNow that you might want to track in an update set are already tracked, due to a dictionary attribute called update_synch, you might just be surprised at how many types of records are not tracked in update sets! For example, scheduled jobs and scheduled script executions are not tracked in update sets, so you either need a tool like this, or you'll need to move these records over manually! Skip to the bottom of this record for a link to the download page. 

Since manual work is for Peons from Warcraft III and not for developers, let's build a better solution while we laugh at the mere mortals that export-then-import their records as XML. 

Read More