Need to populate Business Unit with logged User

Ramadevi
Tera Contributor

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.

@Ankur Bawiskar 

 

bu.JPG

 

2 ACCEPTED SOLUTIONS

@Kusuma Sai 

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.

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

View solution in original post

@Kusuma Sai 

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.

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

View solution in original post

16 REPLIES 16

@Kusuma Sai 

for the user you are using for testing are you sure that BU field is populated

If it's populated then it should work fine

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

Ramadevi
Tera Contributor

getRecord() is not working on scoped applications sir.