- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 01:50 PM
Hi folks
Is there be any difference between the following, specifically in terms of performance?
var value = current.request_item.cat_item;
var value = current.getElement('request_item.cat_item');
Thanks
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- 11,232 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 02:15 PM
Hi Nam,
As far as I know, there's no difference in performance. Both return a GlideElement object. That being said, based on the script you wrote, you are looking for a value and for that you would want getValue() which doesn't work on dot-walking. I haven't tried getElement() with a dot-walk notation. Have you seen it used somewhere? Test it and let me know.
http://wiki.servicenow.com/index.php?title=GlideElement#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 02:15 PM
Hi Nam,
As far as I know, there's no difference in performance. Both return a GlideElement object. That being said, based on the script you wrote, you are looking for a value and for that you would want getValue() which doesn't work on dot-walking. I haven't tried getElement() with a dot-walk notation. Have you seen it used somewhere? Test it and let me know.
http://wiki.servicenow.com/index.php?title=GlideElement#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 08:32 PM
Thanks Chuck,
I've just tested the dot-walked element as above and it does appear to work
Do you know if there is any more efficient way than referencing the GlideElement though?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2017 06:00 AM
Hi Nam,
Dot-walking and getElement() are the two ways to get the GlideElement information.
You ask about performance an efficiency. Are you experiencing issues or just trying to be proactive?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2017 01:32 PM
Hi Chuck,
Yeap I'm having a bit of issue implementing a query restriction, I found that it runs multiple time when, says, a list of parent records is brought up. It slows down the whole system considerably due to that it has to run 4-5 queries on top of the original