logo

NJP

Kamlesh Kumar on LinkedIn: #servicenow #servicenowdeveloper #servicenowcommunity | 15 comments

Import · Dec 15, 2022 · article

For those who are not aware : implementation of getReference in servicenow is with GlideRecord API. So, if you are using getReference, you should know that you are using GlideRecord only. At the backend, getReference uses GlideRecord API to fetch referenced record and that is why you get the whole record in return and not just any single field value. So, when you use getReference("field_name"), then it will be translated to : var gr = new GlideRecord('field_referenced_table'); gr.addQuery("sys_id","referenced_field_value");gr.query()gr.next() return gr; // This returns GlideRecord element itself So, basically, .getReference() is an encapsulation to GlideRecord query which happens at client side. But what about getReference with callback, that is asynchronous right ? Yes, but that's also implemented in the system as GlideRecord but that is GlideRecord with callback function (Yes, at client side GlideRecord() do comes with the flavour of callback function). So, next time whenever you are using getReference(), make sure you know that you have used GlideRecord(). Also, next time in any of your interview if you are asked why getReference() should not be used at client side, I hope you know the complete answer. Note : This information is to let one know why not to use .getReference() and why it's advised not to use it.#servicenow #servicenowdeveloper #servicenowcommunity

View original source

https://www.linkedin.com/posts/kamlesh-kumar-73a29083_servicenow-servicenowdeveloper-servicenowcommunity-activity-7003252950168956928-I3pN/?utm_source=share&utm_medium=member_desktop