- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2025 07:58 PM
Hi,
As per subject I am trying to populate the Caller active status based on the Caller ID field in the Incident form.
I have created a field Caller Status on the Incident form and need the logic to have it auto populate its state based on the Caller ID field.
Please help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2025 09:12 PM
Hi @Happy S
You can use an On-Change Client Script. Refer below screenshots and the code:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var userRef = g_form.getReference('caller_id', userLookup);
function userLookup(userRef) {
alert(userRef.active.toString());
//You can remove this alert and make use of g_form API to set value of your custom field
g_form.setValue('your_field_name',userRef.active.toString());
}
}
Output:
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2025 08:09 PM
why to create a new field on incident form?
you can dot walk and bring the active field from caller
OR
if you still require then onChange client script on caller_id will help, what did you try so far and what didn't work?
It's an easy requirement.
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
01-14-2025 08:26 PM - edited 01-14-2025 08:27 PM
I wanted to have a UI policy based on the caller active status to show/hide certain choices on the incident form.
Tested using UI policy to dot walk to the sys user table but since Caller active status field is not present on the Incident form thus it is not working.
Have tried with Client Script but not working so need the help to get it done.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2025 08:56 PM
when should the check happen? Ideally on change of caller field right?
If yes then onChange of caller field you can know the active field is true/false
why to dot walk in UI policy condition?
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
01-14-2025 09:12 PM
Hi @Happy S
You can use an On-Change Client Script. Refer below screenshots and the code:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var userRef = g_form.getReference('caller_id', userLookup);
function userLookup(userRef) {
alert(userRef.active.toString());
//You can remove this alert and make use of g_form API to set value of your custom field
g_form.setValue('your_field_name',userRef.active.toString());
}
}
Output:
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.