gs.getUserID() is not working ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2019 01:52 AM
Hi Developers,
I have a table as u_shift_allowances_temp and there are 20 records and i want to fetch no.of records which are assigned to "assigned_to" members.
for this i wrote
var rca_table=new GlideRecord("u_shift_allowances_temp");
rca_table.addQuery("u_assigned_to",'00b6ea5edbabba80189d73200f96197b');
rca_table.addQuery('u_state', 'CONTAINS', 'Rejected');
rca_table.query();
while(rca_table.next())
{
gs.print("print:" + rca_table.getDisplayValue('u_assigned_to'));
}
In above query , 2nd line if i will write
rca_table.addQuery("u_assigned_to",gs.getUserID());
It's not fetching any data instead if i will give sys_id of that user, its fetching the data .
Please suggest me what to do here, because i cann't give one sys_id because i want to show the reject records who has uploaded that.
Regards,
Manmath

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2019 02:06 AM
it should work, u_assigned_to is reference type field?
can you do one thing here to troubleshoot this issue.
open table record in list view and in filter pass the u_assigned_to | is | javascript:gs.getUserID()
then validate are you getting some row?
share the screenshot while you test with above point.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2019 02:15 AM
Hi,
Try this:
gs.getUser().getID();
Regards,
Munender

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2019 02:28 AM
Hi Manmath,
Kindly replace your code with below snippet & check.
var u=gs.getUserID();
gs.log('User is ',u);
var rca_table=new GlideRecord("u_shift_allowances_temp");
rca_table.addQuery("u_assigned_to",u);
rca_table.addQuery('u_state', 'CONTAINS', 'Rejected');
rca_table.query();
while(rca_table.next())
{
gs.log("print:" + rca_table.getDisplayValue('u_assigned_to'));
}
Thanks,
Jaspal Singh
Hit Helpful or Correct on the impact of response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2019 02:29 AM
Hi,
I will try ur code it' fine
it's running my instance
var rca_table=new GlideRecord("incident");
rca_table.addQuery("assigned_to",gs.getUserID());
rca_table.addQuery('state', 'CONTAINS', 'new');
rca_table.query();
while(rca_table.next())
{
gs.print("print:" + rca_table.getDisplayValue('assigned_to'));
}
Thanks,
Rahul Kumar