We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Reference Qualifier caller id. Manager should populate inassigned_to field of incident

niharika_l
Mega Contributor

i would like to populate assigned_to field in incident form with caller_id manager

can uh help me with this??

1 ACCEPTED SOLUTION

Nishant8
Tera Sage

Hello @niharika_l , you haven't mentioned when you'd like to set the assigned to field. Please note that Assigned To field is dependent on Assigned Group and should have ITIL users as fulfiller. However, if you have considered all these already, you can use below Script include and client script combo. I'm sharing it to run on On Change.

- Script include: GlideAjax is enabled

var testGetUserDetailsUtil = Class.create();
testGetUserDetailsUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getUserDetails: function() {
        var callerId = this.getParameter('sysparm_user');
        var userGR = new GlideRecord('sys_user');
        if (userGR.get(callerId)) {
            return userGR.getValue('manager') || '';
        }

    },
    type: 'testGetUserDetailsUtil'
});

- Client Script: On change of Caller field

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var ga = new GlideAjax('testGetUserDetailsUtil'); //name of script include
    ga.addParam('sysparm_name', 'getUserDetails');
    ga.addParam('sysparm_user', newValue);
    ga.getXMLAnswer(processManagerResponse);
}

function processManagerResponse(answer) {
    if (answer) {
        g_form.setValue('assigned_to', answer);
    } else {
        g_form.clearValue('assigned_to');
    }
}

 

Regards,

Nishant

View solution in original post

1 REPLY 1

Nishant8
Tera Sage

Hello @niharika_l , you haven't mentioned when you'd like to set the assigned to field. Please note that Assigned To field is dependent on Assigned Group and should have ITIL users as fulfiller. However, if you have considered all these already, you can use below Script include and client script combo. I'm sharing it to run on On Change.

- Script include: GlideAjax is enabled

var testGetUserDetailsUtil = Class.create();
testGetUserDetailsUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getUserDetails: function() {
        var callerId = this.getParameter('sysparm_user');
        var userGR = new GlideRecord('sys_user');
        if (userGR.get(callerId)) {
            return userGR.getValue('manager') || '';
        }

    },
    type: 'testGetUserDetailsUtil'
});

- Client Script: On change of Caller field

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var ga = new GlideAjax('testGetUserDetailsUtil'); //name of script include
    ga.addParam('sysparm_name', 'getUserDetails');
    ga.addParam('sysparm_user', newValue);
    ga.getXMLAnswer(processManagerResponse);
}

function processManagerResponse(answer) {
    if (answer) {
        g_form.setValue('assigned_to', answer);
    } else {
        g_form.clearValue('assigned_to');
    }
}

 

Regards,

Nishant