I want to restrict a user from the "assigned to" list in a change task.

Aditi Khurmi
Tera Contributor

So, I am implementing a doer-checker process for Change Management wherein the person who is the "Doer" of the change request cannot be the "Checker" of the change request. 

I created two automated change tasks (after the change request moves to Implement state) one will be the "Doer" task while the other one will be the "Checker" task. I want to make sure that the user in the assigned to of "Doer" task does not appear on the assigned to reference list of the "Checker" task. 

How can I achieve this?

1 ACCEPTED SOLUTION

Tai Vu
Kilo Patron
Kilo Patron

Hi @Aditi Khurmi 

You can define a function in a script include to build your own custom query for the Assigned to field in the Change Task table.

Sample below we get the Assignee Sys ID from the Does task, then in the Checker task we will filter that User out.

#Script Include

var CLChangeRequestUtil = Class.create();
CLChangeRequestUtil.prototype = {
    initialize: function() {},

    getRefQualChangeTask: function(change_task) {
        var query = 'roles=itil^ORroles=sn_change_write'; //OOTB Default Query in Change Task
        var assigneeDoes = this._getDoesAssignee(change_task);
        if (!gs.nil(assigneeDoes)) {
            query += '^sys_id!=' + assigneeDoes;
        }
        return query;
    },

    _getDoesAssignee: function(change_task) {
        var assigneeDoes = '';
        var grChangeTask = new GlideRecord('change_task');
        grChangeTask.addQuery('change_request', change_task.getValue('change_request'));
        grChangeTask.addQuery('task_type', 'Does'); //replace your task type Does
        grChangeTask.query();
        if (grChangeTask.next()) {
            assigneeDoes = grChangeTask.getValue('assigned_to');
        }
        return assigneeDoes;
    },

    type: 'CLChangeRequestUtil'
};

 

#Dictionary Override

javascript: new CLChangeRequestUtil().getRefQualChangeTask(current);

Timi_0-1703483012086.png

 

Cheers,

Tai Vu

 

View solution in original post

3 REPLIES 3

ersureshbe
Giga Sage
Giga Sage

Hi, Yes, the Reference qualifier is one route. Another Route - When you create a 2 task you can define the simple UI policy or Client script and make it Assignment group field a 'Read Only' field. When you apply the solution - It should apply to your mentioned scenario and it should not affect globally. 

Regards,
Suresh.

Tai Vu
Kilo Patron
Kilo Patron

Hi @Aditi Khurmi 

You can define a function in a script include to build your own custom query for the Assigned to field in the Change Task table.

Sample below we get the Assignee Sys ID from the Does task, then in the Checker task we will filter that User out.

#Script Include

var CLChangeRequestUtil = Class.create();
CLChangeRequestUtil.prototype = {
    initialize: function() {},

    getRefQualChangeTask: function(change_task) {
        var query = 'roles=itil^ORroles=sn_change_write'; //OOTB Default Query in Change Task
        var assigneeDoes = this._getDoesAssignee(change_task);
        if (!gs.nil(assigneeDoes)) {
            query += '^sys_id!=' + assigneeDoes;
        }
        return query;
    },

    _getDoesAssignee: function(change_task) {
        var assigneeDoes = '';
        var grChangeTask = new GlideRecord('change_task');
        grChangeTask.addQuery('change_request', change_task.getValue('change_request'));
        grChangeTask.addQuery('task_type', 'Does'); //replace your task type Does
        grChangeTask.query();
        if (grChangeTask.next()) {
            assigneeDoes = grChangeTask.getValue('assigned_to');
        }
        return assigneeDoes;
    },

    type: 'CLChangeRequestUtil'
};

 

#Dictionary Override

javascript: new CLChangeRequestUtil().getRefQualChangeTask(current);

Timi_0-1703483012086.png

 

Cheers,

Tai Vu