getcontrol vs getelement

amaneet
Kilo Contributor

Hi Folks,

Would like to understand the difference between getelement and getcontrol in client scripting?

Thanks,

Aman

2 REPLIES 2

Rajender1
Mega Sage

Hi amaneet,


i find this link   in community Get Element value - scripting


please have look for 10.3 and 10.6 chapters


GlideForm (g form) - ServiceNow Wiki


Harneet Sital
Mega Sage
Mega Sage

Hi Amaneet,



getControl() method uses the field name while getElement() uses the ID of the element from the page. Moreover getControl() is similar to document.getElementById('id'). It gets the element with the field name you specify (not an id). It's important for fields like Reference fields which are actually made up of several different input fields in the DOM (one for the sys_id, one for the display value, etc). getControl() knows which input element to get.



find_real_file.png