logo

NJP

ServiceNow Things to Know 123: addExtraField

Import · May 20, 2024 · article

Hello Everyone,

In the Washington DC release, there is a new GlideRecord method called "addExtraField" that can help us write more efficient queries, especially when dot walking. The difference is observed when trying to dotwalk more than 2 layers.

It allows you to query dot-walked fields in a single database request, rather than perform multiple queries per dot-walked element in a form or script (which requires multiple round trips to the database)

Example

var gliderecord = new GlideRecord("incident");

gliderecord.addQuery("number", "INC0041457");

gliderecord.addExtraField("cmdb_ci.location.contact.name");

gliderecory.query();

gliderecord.next();

gs.info(gliderecord.cmdb_ci.location.contact.name);

If my content helped you in anyway, please mark this content as BOOKMARK, SUBSCRIBE & HELPFUL

Best Regards,

Prashant Kumar (LearnIT)

YouTube Channel LearnIT: https://www.youtube.com/@learnitwithprashant

Blog LearnIT: https://medium.com/@LearnITbyPrashant

Prashant Kumar LinkedIn: https://www.linkedin.com/in/learnitbyprashant/

ServiceNow Community Prashant Kumar - https://www.servicenow.com/community/user/viewprofilepage/user-id/19635

View original source

https://www.servicenow.com/community/developer-blog/servicenow-things-to-know-123-addextrafield/ba-p/2936154