How to set reference field value by using setValue()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 03:31 AM
var user=g_form.getReference('requested_for',doAlert);
function doAlert(user)
{
g_form.setValue('manager',user.manager);
}
By using this script I got sys_id but actually I need the name of manager how can I get
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 07:42 AM - edited 06-17-2024 07:47 AM
Try using:
g_form.setValue('manager',user.manager.name);
Also other advice:
1. Rather than using getReference with a callback, consider doing this using GlideAjax and a Script Include ( More efficient as getReference will return all the data of the record whereas with GlideAjax you can get the data you want)
2. You could also get the users manager in a Display Business Rule and store it in scratchpad. That way you can access the scratchpad at anytime whilst on the form.
e.g. g_form.setValue('manager',g_scratchpad.managerName)
Regards
Paul