- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2021 12:26 AM
What is the difference getElement() and getValue()?
Please tell me with examples..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2021 08:42 PM
Hi Prasanthi,
I hope below Example will clear your confusion
var gr = new GlideRecord('incident');
gr.setLimit(1);
gr.query();
gr.next();
gs.print(gr.getValue('assignment_group')); // how the direct field script looks
gs.print(gr.getValue('assignment_group.manager')); // Doesnt work
gs.print(gr.assignment_group.getValue('manager')); // Doesn't work
gs.print(gr.assignment_group.manager.getValue()) // We have to resort to the GlideElement version for dot walking
gr.getElement('assignment_group.manager').getValue(); // Closest alternative? But still using GlideElement
In the above script, we can see that the GlideRecord getValue accepts a string parameter but it can not be a dot walked field. For dot walking, we are forced to resort to the GlideElement version of getValue which does not accept a string value.
Please mark helpful if answer is correct.
Thanks,
sushma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2021 05:09 PM
We prefer getValue(), that is ok . I am asking that both functionality is same right or wrong? please tell me that one.
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2021 11:23 PM
Hi Prasanthi,
Functionality is different for both.
Thanks,
Murthy
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2021 05:14 AM
Hence please tell me the difference....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2021 05:54 AM
Hi Prasanthi,
document.getElementById() is a DOM manipulation method to get the element from HTML code with the Id. As id for every element is different it can be used to get that particular element by it's ID (more like a unique key).
But getValue() is used to return the value of the particular field.
Hope you understand now.
Thanks
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2021 08:42 PM
Hi Prasanthi,
I hope below Example will clear your confusion
var gr = new GlideRecord('incident');
gr.setLimit(1);
gr.query();
gr.next();
gs.print(gr.getValue('assignment_group')); // how the direct field script looks
gs.print(gr.getValue('assignment_group.manager')); // Doesnt work
gs.print(gr.assignment_group.getValue('manager')); // Doesn't work
gs.print(gr.assignment_group.manager.getValue()) // We have to resort to the GlideElement version for dot walking
gr.getElement('assignment_group.manager').getValue(); // Closest alternative? But still using GlideElement
In the above script, we can see that the GlideRecord getValue accepts a string parameter but it can not be a dot walked field. For dot walking, we are forced to resort to the GlideElement version of getValue which does not accept a string value.
Please mark helpful if answer is correct.
Thanks,
sushma