Difference between dot-walk and getElement()

Nam Nguyen
Tera Expert

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

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

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


View solution in original post

9 REPLIES 9

Chuck Tomasi
Tera Patron

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


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?


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?


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