- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 01:53 PM
Hello ServiceNow community.
I hope you're doing well.
I'm currently attempting to create a pop-up message showing a user's department in ServiceNow once their profile record is selected on the sys_user table.
I attached my solution below which I thought would give me the user's department, but is instead giving me their name.
If you have any insights on how to fix this, it would be most appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 03:14 PM
Hi @Philip Conforzi ,
Department is reference type field on User form, so its not giving the value via g_form.getValue('department');
Use the below code.
function showDept(){
var dept = g_form.getReference("department", displayDept);
function displayDept(dept){
alert("Department->"+dept.name);
}
}
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 03:14 PM
Hi @Philip Conforzi ,
Department is reference type field on User form, so its not giving the value via g_form.getValue('department');
Use the below code.
function showDept(){
var dept = g_form.getReference("department", displayDept);
function displayDept(dept){
alert("Department->"+dept.name);
}
}
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 05:29 AM
Hello,
Thanks for your solution!
I've tried it out but I can't seem to get the alert message to show up when I open a user record form the sys_user table.
Any thoughts??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 05:43 AM - edited 02-07-2024 05:44 AM
Just confirming if you update the onClick field with the function name. highlighted in yellow in my previous reply.
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 06:03 AM
Hello,
Yes I updated it but wasn't able to see anything run. Please see the image I've pasted below to see my full UI action as it is now. Thanks again for your input, appreciate it!