- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 12:44 AM
Hi, am trying to get user details in scoped application and using the following syntax:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 01:54 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 12:51 AM - edited 03-01-2023 12:51 AM
it's not supported in scoped app
please query the user table with logged in user sysId and get the employee_number
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 02:05 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 12:56 AM
Hi @Aavi ,
you can use GlideRecord refer below.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0723759
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 01:54 AM
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