Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

gs.getUser().getRecord() Not the same as GlideRecord('sys_user') ??

Shane11
Mega Expert

Hi All,
I'm getting different results on two things I thought were essentially interchangeable.

var usrID = gs.getUserID();
var gr = new GlideRecord('sys_user');
if(gr.get(usrID)) {
     gs.print(gr.getValue('u_default_group'));
}

OUTPUT: 6f028386d0aea0007f0059dfebc05518



var gr = gs.getUser().getRecord();
gs.print(gr.getValue('u_default_group'));

OUTPUT: null

The 'u_default_group' field is the only field we've added to the table that doesn't work, but it's also the only reference field we've added.
I know
gs.getUser().getRecord()
returns a 'GlideMemoryRecord' not a 'GlideRecord' but is there a reason why this specific field doesn't work?

Thanks in advance
2 REPLIES 2

CapaJC
ServiceNow Employee
ServiceNow Employee

If you log out and back in, does it work? Perhaps the GlideMemoryRecord gets cached at login.


Shane11
Mega Expert

Thanks once again CapaJC!

I did not know that it was cached.