field not populated in ESC view

dev_K
Tera Contributor

 

 

function onChange(control, oldValue, newValue, isLoading) {
    // Prevent the script from running if the form is loading or the new value is empty
    if (isLoading || newValue === '') {
        return;
    }

    // Get the sys_id from the 'sysid' field
    var memberSysID = newValue;

    // Create a GlideRecord object for the 'sys_user_grmember' table
    var grMember = new GlideRecord('sys_user_grmember');
    if (grMember.get(memberSysID)) {
        // If the record is found, retrieve the 'group' sys_id from the member record
        var groupSysID = grMember.getValue('group');

        // Create another GlideRecord object for the 'sys_user_group' table
        var grGroup = new GlideRecord('sys_user_group');
        if (grGroup.get(groupSysID)) {
            // Retrieve the 'name' property from the group record
            var groupName = grGroup.getValue('name');
            // Set the value of the 'group_sysid' field
            g_form.setValue('group_sysid', groupName);
        } else {
            // Clear the 'group_sysid' field if no group record is found
            g_form.setValue('group_sysid', '');
        }
    } else {
        // Clear the 'group_sysid' field if no member record is found
        g_form.setValue('group_sysid', '');
    }
}

 

 

 

 

The following script is supposed to retrieve the sysID field value and then query groups table to retrieve the name of the table:

 

dev_K_1-1727699425578.png

 

 

it works on the backend, but when i test it in ESC this field is not getting populated:

 

dev_K_2-1727699487538.png

 

 

 

any ideas why?

10 REPLIES 10

@dev_K Sent you a direct message. Please check.