- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 07:06 AM
Hi, I have a enhancement with scoped application catalog Item.
I have only 1 variable i.e., 'BU'. I need to populate Business Unit(u_bu) form logged user and it's comes from User profile .
Business Unit is a choice field on User table.
Example : If I am Impersonate with another user I need to populate his Business Unit on the Field.
kindly help me.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 12:07 AM
you should have mentioned that you are using the variable in scoped app
For scoped app use this
javascript: var val; var rec = new GlideRecord('sys_user'); rec.get(gs.getUserID()); val = rec.u_bu; val;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 01:25 AM
Sorry didn't get your question?
BU is a choice field on sys_user and you want to see Label and not choice value?
if yes then use getDisplayValue()
javascript: var val; var rec = new GlideRecord('sys_user'); rec.get(gs.getUserID()); val = rec.u_bu.getDisplayValue(); val;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 12:18 AM
yes
Ensure you use correct field name from sys_user which holds the BU
I used u_bu; you use yours
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 12:37 AM
Values is placing sir, I need to populate the Labels, kindly suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 12:38 AM - edited 05-10-2023 12:41 AM
Here placed the BU choice Values sir, please suggest to place the Labels
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 01:25 AM
Sorry didn't get your question?
BU is a choice field on sys_user and you want to see Label and not choice value?
if yes then use getDisplayValue()
javascript: var val; var rec = new GlideRecord('sys_user'); rec.get(gs.getUserID()); val = rec.u_bu.getDisplayValue(); val;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 03:25 AM
Hi sir, it's working me as system administrator. May I know what is the role i have to provide end users to working.
Am impersonate with end user it's not working.
Both default value and client script needs work as end user. Please suggest