[object GlideRecord] instead of record sys_id

Lon Landry4
Mega Sage

Howdy Community,

The below script returns User is [object GlideRecord] instead of a sys_id.

I can create log messages that verify the current.variables.n_user below.

The variable is of the string type from a single line text field.

`Tried adding .sys_id in various places, creating other variables that are dot walked, & getRefRecord.

But, log messages reveal value is [object GlideRecord] instead of a sys_id.

Any ideas how to make this work?

 

var rqstdFor = current.variables.n_user;
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',rqstdFor.sys_id);
gr.query();
gs.addInfoMessage('User is '+gr);

 

Also tried

var rqstdFor = current.variables.n_user;
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',rqstdFor);
gr.query();
gs.addInfoMessage('User is '+gr);

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Hi @Lon Landry4 

if you refer to your code line:

gs.addInfoMessage('User is '+gr);

then yes, the output is correct as gr is an object.

You have to change it to 

gs.addInfoMessage('User is '+gr.getValue('sys_id'));

if you want to see any sys_id

Maik

View solution in original post

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Hi @Lon Landry4 

if you refer to your code line:

gs.addInfoMessage('User is '+gr);

then yes, the output is correct as gr is an object.

You have to change it to 

gs.addInfoMessage('User is '+gr.getValue('sys_id'));

if you want to see any sys_id

Maik

Lon Landry4
Mega Sage

Thank you! I have been at this six 6am us central time.