Question onChange client script on the reference field gets changed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
In client script onChange logic if we have changed the Caller name, as Caller field is a reference field in the onChange function the oldValue or the newValue is giving the sys_id of the field not the exact name of the caller, now the name of the Caller we can get from the User table, so how we will fetch this username from the client script, so the username should be displayed as an alert message when the caller field gets changed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
this is simple
use this to get the display value of caller_id user
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var displayName = g_form.getDisplayBox('caller_id').value;
alert(displayName);
}
If you want to get the user_name then use this script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var callerUserName = g_form.getReference('caller_id').user_name;
alert(callerUserName);
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
2nd one solution is working , but my query is "if I'm changing the value of caller field then in the following function
