BR is not working

Madhavi2
Tera Contributor

Hi All,

 

I am trying below code.

 

var usr=gs.getUserName();
gs.addInfoMessage("usr"+usr);
var pc=new GlideRecord("cmn_location");
pc.addQuery('name',usr);
pc.query();
if(pc.next())
{
var flag=pc.name;
gs.addInfoMessage(flag);
}
else
{
flag=111111;
gs.addInfoMessage(flag);
}
 
Even though logged in user is available in location table still it is going to else loop. Any inputs on what I'm missing. 
Same script is working in background script with hardcoded user name.
Thank you.
5 REPLIES 5

vamsi krishna8
Tera Contributor

hello @Madhavi2 
Good Day !!

var pc=new GlideRecord("cmn_location"); // here ur querying on location table
pc.addQuery('name',usr); // but here , name in location table represents the name of the location , see the attachment below.
vamsikrishna8_1-1710323852300.png

so if you want to query the location table based on user name then add query with field name that contains user name as value.