Eliminate Unnecessary Queries With This Simple Check
Developing Creative Business Solutions On ServiceNow on CodeCreative | A ServiceNow Blog
·
Apr 26, 2017
·
article
When I first write a script include to manipulate a GlideRecord, I usually script it to accept a sys_id or other query criteria as a parameter. Its the obvious first step, the GlideRecord has to be retrieved to manipulate it after all. Take this guy for example: var Test = Class.create(); Test.prototype = { initialize: function() { }, doSomethingAwesome: function(id) { var gr = new GlideRecord('incident'); if (gr.get()) { // Something awesome gets done here } }, type: 'Test' }; The more I use the script, though, the more likely I am to run into a scenario where I already have the GlideRecord queried from another script.
View original source
https://codecreative.io/blog/eliminate-unnecessary-queries-with-this-simple-check/