gs.getUserID() is not working ?

manmathpanda
Giga Guru

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

 

 

6 REPLIES 6

Harsh Vardhan
Giga Patron

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. 

Munender Singh
Mega Sage

Hi,

 

Try this:

gs.getUser().getID();

 

Regards,

Munender

Jaspal Singh
Mega Patron
Mega Patron

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.

 

 

Rahul Kumar17
Tera Guru

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'));
}
If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar