We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to populate choice filed value based on other field

seenu_pvr
Tera Contributor
Dear Friends,
 
I have a on change client script where I need to populate the channel field as self service when the caller id role is ITIL. but I cant populate the channel field as self servcie. please advise. Here is the On change script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }


    var gr = new GlideRecord('sys_user_has_role');
    gr.addQuery('user.sys_id', newValue);
    gr.addQuery('role.name', 'itil');
    gr.query();
    //g_form.addInfoMessage(newValue);
    if (gr.next()) {
        g_form.getOption('contact_type', 'self-service');
       // g_form.addInfoMessage("iam in if loop");

    } else {
        g_form.getOption('contact_type', 'None');
       // g_form.addInfoMessage("I am in else loop");
    }
0 REPLIES 0