getRecord() not working in scoped application

Aavi
Mega Guru

Hi, am trying to get user details in scoped application and using the following syntax:

var empid= gs.getUser().getRecord().getValue('employee_number');
 
It's perfectly working in global but not in scoped. 
 
Any help will highly appreciated
 
1 ACCEPTED SOLUTION

aditya174
Tera Guru

Hi @Aavi,

 

Please try this code :

var user_id = gs.getUser().getID();
var gr = new GlideRecord('sys_user');
gr.get(user_id);
var userSource = gr.getValue('employee_number');
var empid= userSource;

 

Please mark my answer as helpful if it serves your requirement.

 

Regards,

Aditya

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Aavi 

it's not supported in scoped app

please query the user table with logged in user sysId and get the employee_number

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Aavi 

I already mentioned getRecord() is not supported in scoped app and you need to use query.

Would you mind marking my response as correct as well since I also provided the correct solution.

As per new community feature you can mark multiple responses as correct.

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Pavankumar_1
Mega Patron

Hi @Aavi ,

you can use GlideRecord refer below.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0723759

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

aditya174
Tera Guru

Hi @Aavi,

 

Please try this code :

var user_id = gs.getUser().getID();
var gr = new GlideRecord('sys_user');
gr.get(user_id);
var userSource = gr.getValue('employee_number');
var empid= userSource;

 

Please mark my answer as helpful if it serves your requirement.

 

Regards,

Aditya