type of gr.active

RAHUL Khanna1
Mega Guru

Hello Folks,

can any body clear me on this ...

var gr = new GlideRecord('sys_user');

gr.get('user_name', 'XXX');

1) gs.print(typeof gr)

2) gs.print(typeof gr.active);

both are object type ...what is the difference between object-1 and object-2

I could get all the properties of all the object-1 , where as I could not in object-2.

Also ----> gs.print(gr.active == true) <------------> gs.print(gr.getValue('active') == true)---------->gs.print(gr.getValue('active') == 'true')

can any body please make me understand above statements.

 

7 REPLIES 7

Servicenow behaves here in a different way Rahul.

Let me tear up the answers for your questions :

var gr = new GlideRecord('sys_user');

gr.get('user_name', 'XXX');

1) gs.print(typeof gr)

2) gs.print(typeof gr.active);

both are object type ...what is the difference between object-1 and object-2

 

Yes, Both are object Type. The difference between Object 1 and Object 2 is Object 1 is the GlideRecord Object where as the object 2 is Glide Element Object , so the typeof returns the object 

The getValue() method on the GlideRecord object return value is string so what it internally does is it picks the primitive value from that glideelement object returned 

find_real_file.png

Hope this helps 

Mark this response as correct if that really helps 

 

Thanks,

Siva

var gr = new GlideRecord('sys_user');
gr.get('user_name', 'admin');

gs.print(gr.active == true);//--->true
gs.print(gr.getValue('active')==true)//---->true
gs.print(typeof gr.getValue('active') )//-->string
gs.print(typeof 'true' )//-->string
gs.print(gr.getValue('active')=='true')//---->false--> I am confused with this ..can you please explain thist.

Also , what is the difference between GR object and GE object ....

GlideRecord object contains each individual field information on the table as a single GlideElement Object and gr.field_name retrieves the information from this GlideElement Object only.

Refer the image below for a reference 

find_real_file.png

In this way each field will be of a GlideElement Object 

 

Hope this helps 

Mark this response as correct/helpful if that really helps

 

Thanks,

Siva