- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Hi Everyone,
Welcome back to my weekly blog post series of ServiceNow features in Washington DC release for week 2.
Week 2: addExtraField()
With Washington DC release, ServiceNow brought a new GlideRecord API method "addExtraField()" for global applications.
There have been many cases where you would like to get data for dot-walked fields in your script. When we perform such queries in our script, it makes multiple database calls (per dot=walk element in a form or script) and reduce the performance, but not anymore, with this new method we can get the dot-walked information in a single datable request which increases the efficiency and performance of our code.
Below is an example of a script to fetch the email of the person whom the problem is assigned, and the problem record is referenced in an incident.
var gliderecord = new GlideRecord("incident");
gliderecord.addQuery("number", "INC0000002");
gliderecord.addExtraField("problem_id.assigned_to.email");
gliderecord.query();
gliderecord.next();
gs.print(gliderecord.problem_id.assigned_to.email);
//Output
//problem.coordinator_b@example.com
In the above script we will get the same result without using addExtraField() method, but by using it we are optimizing the efficiency of code by reducing the database calls.
You can find the official documentation here.
Regards,
Mohit Kaushik
2XServiceNow MVP (2023-2024)
- 805 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.