Using .addJoinQuery() & How to Query Records with Attachments in ServiceNow

Here’s a common question:

“How do I use a scripted GlideRecord query to get all records in a given table that have attachments?”

Often, people in the Community Forums will suggest querying the table, iterating through every single record, running .hasAttachment() on every single one, and adding those records to a list if that returns true.

Or, they might suggest querying the sys_attachment table, querying every attachment associated with the target table, pushing every unique value from the attachment record's `table_sys_id` field into an array, then using that array to query the target table with something like grMyRecord.addQuery('sys_id', 'IN', arrRecordsWithAttachments.join(','));.

However, these solutions are quite slow and not exactly ideal. Instead, consider the use of GlideRecord's .addJoinQuery() method.

Consider the following code…

Read more

Free, Simple URL Shortener for ServiceNow Nerds (snc.guru)

🛠️That’s right folks, it's yet another FREE ServiceNow tool on SN Pro Tips!🔧

This one is a URL Shortener that uses the fancy-fun-fresh "snc.guru" domain, so you can look like a really heckin' hoopy frood when you share a link to your blog post, a resource you found, etc.

Create short, memorable, easy quick-links with the easy-to-remember pattern: go.snc.guru/your_thing
Start creating your own custom ServiceNow-ey short-URLs with snc.guru with just a few clicks. Head over to short.snc.guru, or click “Read more” to use what might be the world’s simplest URL shortener!

Read more

How to Get and Parse ServiceNow Journal Entries as Strings/HTML

I come across this question all the time in the ServiceNow community forums, and in the ServiceNow developer community Discord, Slack, and Telegram groups.

“How do I get the last N journal entries from a record in ServiceNow, in a script?”
“How do I print the last N journal entries in my notification email or mail script in ServiceNow?”
“How do I parse journal entries for HTML so special characters and line-breaks will show up properly in HTML or an email?”

I’ve helped people create so many one-off solutions to these questions that it felt more efficient to, finally, just create a single function that can do it all!

Click below to be taken to the article, and get the free tool that you can add your instance!

Read more

New tool: Get Latest Version of ServiceNow Docs Page

Imagine you’re searching for an issue you’re researching in ServiceNow, and the first result you find on Google is a ServiceNow documentation page… from the Jakarta version of ServiceNow. It’s totally out of date.

How do you make sure that you’re getting the latest version of this same page in the documentation?
And what if you want to share the link to the latest version of that doc with someone else?
What if, for example, you’re posting to the community forums and you want to make sure that the link you post will always go to the latest version of that doc, even if someone sees the link years later?

With this extension (or bookmarklet script), you can be on any ServiceNow Docs page and simply click one button to (1) have the URL of the latest version of that article copied to your clipboard, and (2) be redirected to the latest version of that page.
The best thing about that generated link is that even if you were to navigate to it again years later, it would still take you to the latest version of that page, even if the “latest version” is newer than the version that was the latest when you generated the link!

Read more