Servicenow Gliderecord Cheat Sheet



  • Scheduled jobs are an extremely useful way to automate processes in Service-now.com and lift some of the administrative burden of the tool off of the shoulders of your Service-now administrators. It’s very easy to create a scheduled job or a scheduled import. Typically there’s no scripting or advanced configuration involved at all. Just set it up.
  • 4: mergeToGR: This is a best example to write some fields to the GlideRecord, and this can be used to eliminate multiple GlideRecords. The parameters which are needed are as below. Hashmap:The object with the data to be written to the GlideRecord; GlideRecord: The GlideRecord which would get the data from the hashmap.
  • ServiceNow Elite The most common and fundamental scripting used in ServiceNow is GlideRecord. Alter and reuse these scripts found in this post for your ServiceNow implementation. Important Note: Always run GlideRecord statements in a development instance first and make sure they work correctly before using in production!
  • View gliderecordcheatsheet.md. GlideRecord & GlideAggregate Cheat Sheet. ServiceNow UI Developer cheat sheet. URL Purpose /stats.do: Quick stats.

If you want to deep dive how to customize SN Components via new Tech Stack – read this article.

New ServiceNow features introduced in Madrid and enhanced in New York comes with more modern technology stack.

  • The core component of newly designed pages is not a Jelly UI page anymore (it still is for Service Portal – $sp.do), but it is done with modern JS frameworks like React or ServiceNow JavaScript UI Framework. That means no Java and no Jelly.
  • To access other specific components, there are at least 50 new OOTB undocumented REST API’s to perform ServiceNow functionality which was only possible by old school HTTP requests only (history, favorites, breadcrumbs, filters, date, impersonation, UI action, etc.). This means almost all the required functionality is accessible in the front end.
  • However, not everything is upgraded to new stack yet, there are still some iFrames that call Jelly pages and some REST API’s are missing. Those too can be called using REST API’s, but it’s complicated.
  • More API’s and more components are coming to ServiceNow. A lot of performance optimizations happen when you move away from Java and Jelly.

User Object Cheat Sheet - ServiceNow Guru. User Object Cheat Sheet N o matter what system you’re working in, it is always critical to be able to identify information about the user who is accessing that system. GetCompanyRecord Returns the company GlideRecord of the currently logged-in user. Var company = gs.getUser.

But the natural problem arises: if we have so many different REST API’s to call to fill our page with everything we need, it becomes too complicated to continue developing and grow. We need some way to perform BATCH REST API operations.

Here is where GraphQL comes to ServiceNow.

As REST replaced SOAP, it is believed by some, that GraphQLwill replace REST due to handy benefits: Youtube mp3 converter for mac download.

  1. You only call one endpoint to get all the date instead of calling many – you do not need to call 20 different REST API’s to get all information into one page
  2. You only get the data you ask for and not what REST API developer wanted you to get – you only get what you ask for, so you can limit the transaction size to be as little as possible – hence performance increase

It iIt is also possible to use GraphQL for your ServiceNow integrations and ditch REST API’s.

  1. You only need to call one endpoint with POST for everything you need.

Share it app for mac pc. /api/now/graphql?api=api

2. All the parameters are in request body.

How do I call ServiceNow using GraphQL?

For example, if you wanted to get encodedRecord, sys Id and record values for specific incident:

P2p for mac osx. We can also retrieve any other elements from the page (related lists, UI actions, formatters, etc.) or perform GlideRecord equivalent operations, like isValidRecord, lastErrorMessage, canReadRecord.

To get all incidents, it looks more complicated, but way less complicated than the old way. Remember this is all done from client side and you have access to anything you ask for.

Also, as this is fully undocumented yet, I haven’t spent much time around to find the ideal queries. This probably could be optimized a lot.

What are other tools in ServiceNow to support GraphQL?

Servicenow Gliderecord Get

1 ) You can debug GraphQL execution by opening “Debug GraphQL” module. Session debugger was greatly enhanced with New York release, but is possible in Madrid as well the same way you debug service portal. More can be found here.

Servicenow Gliderecord Cheat Sheet 2018

You can do some ‘mouse clicking’ in ServiceNow UI while session debugger is running and copy your GraphQL queries.

Gliderecord

2) GraphQL subscription feature might enable you to build modern pub/sub message queues for client-side application solutions. Same as for AMB and AngularJS record watchers you could define subscriptions (ServiceNow calls them ‘Channel Responders’). With GraphQL you can do the same by utilizing sys_rw_amb_graphql_action table, which extends sys_rw_amb_action.

3) All transactions using GraphQL have “Batch REST” type andcannot be tracked separately. Logging can only be enabled at node levelenabling advanced REST debugging.

Previously, I posted an example of how to get distinct records using GlideAggregate. Today I want to share some further powerful examples of GlideAggregate.

First off, you can grab the JavaScript file for GlideAggregate showing all the functions you can use, from right here: GlideAggregate JS. Alternatively, you can always grab the entire library of Service-Now JavaScript objects and functions.

Servicenow Gliderecord Cheat Sheet 2020

Key Functions

  • addAggregate(type) – Add a new statistical function to the query, such as Count, AVG, Max.
  • groupBy(field) – The field you’re running statistics on. If you want to know how many items are assigned to someone, you’ll group by the field “assigned_to”
  • orderByAggregate(field) – If you’re looking for who is assigned the most items, you would order by “count”.
  • getAggregate(type) – Use this inside your while loop to get the Count, AVG, Max statistic that you were querying for.
  • addHaving(type, operator, value) – This is a great way to be able to limit your results. For example, I can write a query to only return users that have at least 10 active tasks assigned to them.

Example Background Scripts

If you aren’t sure what a Background Script is, or how to run one, check out this blog post.

Activate All Roled Users

Count Incidents Opened This Month

Count Incidents Resolved Today

Count Incidents Resolved Yesterday

Find Tasks with more than one SLA of the same type

Helpful Function to get Average Survey Scores

Have More Examples?

If you have any creative uses of GlideAggregate, please feel free to share them in the comments! And as always, never hesitate to ask any questions you might have.

How to Use Background Scripts ›

Categories: Developers, Scripting Tips