How to populate the Caller active status based on the Caller ID field in the Incident form

Happy S
Tera Expert

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.

1 ACCEPTED SOLUTION

Amit Verma
Kilo Patron
Kilo Patron

Hi @Happy S 

 

You can use an On-Change Client Script. Refer below screenshots and the code:

AmitVerma_0-1736917759992.png

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:

AmitVerma_1-1736917897511.png

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@Happy S 

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.

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

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

@Happy S 

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.

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

Amit Verma
Kilo Patron
Kilo Patron

Hi @Happy S 

 

You can use an On-Change Client Script. Refer below screenshots and the code:

AmitVerma_0-1736917759992.png

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:

AmitVerma_1-1736917897511.png

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.