How to query the user table in client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2016 07:34 AM
How to query the user table in client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2016 07:41 AM
If you are trying to look for a record or value on the user table you can use a Glide Record.
var gr = new GlideRecord('sys_user');
gr.addQuery('name_of_field', value)
gr.query()
more information on GlideRecord can be found below :
http://wiki.servicenow.com/?title=GlideRecord#gsc.tab=0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2016 07:59 AM
Hi Biswajyoti do you need to check multiple records?
if suppose there is a field(xyz) which refers to the "user" table then you can do this:
var abc = g_form.getValue('xyz');
var gr= new GlideRecord('sys_user');
gr.addQuery('sys_id',abc);
gr.query();
if(gr.next()) OR while(gr.next())
{
then perform action
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2016 08:08 AM
Everything above is true. But, the best practice is NOT to use GlideRecord in a client script. Please avoid it and use GlideAjax instead! Please refer to GlideAjax for further details!
Depends on your needs you can use a g_scratchpad as well: Scripting with display business rules
Cheers,
Kostya