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.

Gliderecord in client script

Anirban Roy
Mega Guru

Hi,

Why gliderecord query does not return results while using in client scripts for non-admin users?

e.g. 
var group = g_form.getValue('assignment_group');
var user = g_user.userID;

var ir = new GlideRecord('sys_user_grmember');
ir.addQuery('group', group);
ir.addQuery('user', user);
ir.query();

if(ir.next()){
g_form.setValue('assigned_to', user);
alert(ir.sys_id+'if');
}else{
alert(ir.sys_id+'else');
}

 

  • If code runs with admin user logged/ impersonated, it alerts sys_id with 'if' string.
  • If code runs with a non admin user logged/ impersonated, it alerts 'undefined' with 'else' string.
PS: I know, we should not use do sync calls to server from client unless required, and also gliderecord should not be used in a client script/ or client side scripts. But I am curious to know the reason, that script behaves differently for admins and non-admins.

Regards,

Anirban

1 ACCEPTED SOLUTION

The table glided is on 'sys_user_grmember', however I still tried to test by deactivating the before query BR you mentioned. Did not return result either with non-admin.

View solution in original post

8 REPLIES 8

no, not the case.
You may try the example in personal instance.

Hi 

Check the BR i.e user query which defines the sys_user(User table) only for admin(till kingston version) and for admin,user_admin(From London). Check that query BR.

The table glided is on 'sys_user_grmember', however I still tried to test by deactivating the before query BR you mentioned. Did not return result either with non-admin.

Omkar Mone
Mega Sage

That BR mudt be causing this kind of effect.