Restrict Assigned to field on problem record

sureshp89882164
Tera Contributor

Need help on to restrict Assigned to field on problem record. Should be writable by current Assignment Group and Global problem management team only. Assigned to field should be writable by everyone when problem record is creating.

5 REPLIES 5

Deepak Shaerma
Kilo Sage

Hi @sureshp89882164 

You can also achieve this functionality with the help of Onload Client Script and Client Callable Script Include :

OnLoad Client Script:

function onLoad() {
    if (g_form.isNewRecord()) {
        g_form.setReadOnly('assigned_to', false);
        return;
    }
    var assignmentGroup = g_form.getValue('assignment_group');
    var userSysId = g_user.userID;
    if (assignmentGroup) {
        var ga = new GlideAjax('CheckUserAssignmentGroup');
        ga.addParam('sysparm_name', 'isUserInAssignmentGroup');
        ga.addParam('sysparm_user', userSysId);
        ga.addParam('sysparm_group', assignmentGroup);
        ga.getXMLAnswer(function(response) {
            if (response === 'true') {
                g_form.setReadOnly('assigned_to', false);
            } else {
                g_form.setReadOnly('assigned_to', true);
            }
        });
    } else {
        g_form.setReadOnly('assigned_to', true);
    }
}


Script Include :

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

    isUserInAssignmentGroup: function() {
        var userSysId = this.getParameter('sysparm_user');
        var groupSysId = this.getParameter('sysparm_group');

        var healthGroupSysId = '24e93416c35c6a10f99dba2ed4013147'; //Replace your Group Sysid
        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('user', userSysId);
        var groupQuery = gr.addQuery('group', groupSysId);
        groupQuery.addOrCondition('group', healthGroupSysId);
        gr.query();
        if (gr.next())
            return 'true';
        else
            return 'false';
    }

});

change your table to problem.

DeepakShaerma_0-1746786859429.png

DeepakShaerma_1-1746786891783.png

 

If my response helped please mark it correct.

Regards
Deepak Sharma