Get User by UserID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 06:20 AM
in an UI action, I am trying to get User Object for the engineer selected by the user in the engineer field on the form.
var engUserID = current.engineer.user_name;
var thisUser = gs.getUser();
var engineerUser = thisUser.getUserByID(engUserID);
But it is giving error "Cannot find function getUserByID in object com.glide.script.fencing.ScopedUser"
Later I want to check if engineerUser is in some specific role..
How do I go about doing this validation or is there any other API I can use.
Thanks in advance for any help
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 06:33 AM
Hi Prashant,
It won't work in scoped app.
can you tell what is your requirement?
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 07:16 AM
User will be submitting a new request in a scoped app. One of the fields he will select is Engineer for this request who will approve it. So Engineer field on the form is a reference field to Sys User table. Since I can't put constraint on which user he will select from the many users, before submitting the request, in Submit Request UI Action, I want to check if the engineer selected has a particular role.... hence in my script above, i will be doing hasRole check on the engineerUser object.
But I can't get to that object due to this limitation of scoped app GlideUser API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 06:40 AM
you can write a display BR and set g_scratchpad.xxx with any data you need.
then use g_scratchpad.xxx in your UI Action.