what is the difference between getElemet and getValue

Prasanthi1
Giga Contributor

What is the difference getElement() and getValue()?

Please tell me with examples..

1 ACCEPTED SOLUTION

Sushma Dhandge
Giga Contributor

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

View solution in original post

9 REPLIES 9

Prasanthi1
Giga Contributor

We prefer getValue(), that is ok . I am asking that both functionality is same right or wrong? please tell me that one.

 

Thank You

Hi Prasanthi,

 

Functionality is different for both.

 

 

Thanks,

Murthy

Thanks,
Murthy

Hence please tell me the difference....

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

Thanks,
Murthy

Sushma Dhandge
Giga Contributor

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