ITSM:Only ITIL Assignment groups

Prasnajeet1
Giga Guru

Hi Expert

 

I have a requirement to implement in all ITSM module, "As an IT user should have the ability to assign tickets only to IT groups. This should be across all ITSM modules .Also if tickets are assigned to any groups without members should giving warning message " Please select a valid group which has members" . 

What I mean is  when an user having ITIL role then in the assignment group he/she should able to view only group those are belongs to itil. I mean in the group table if the group "type" is "itil" then that assignment group will visible to ITIL user. Also there is no user availabel in the select assignment group then it should throw a warning message " Please select a valid group which has members" .

 

Please help with the requirement. What type of script or configuration I have to write here.

 

Thanks in advanced.

1 ACCEPTED SOLUTION

You should create a business rule on incident table and should run on update. the condition should be when assignment group changes and assignment group is not empty. 

 

Below script should satisfied the requirement : 

var assignmentGroup = current.assignment_group; 
//Glide group member table
var gmember = new GlideRecord('sys_user_grmember');
gmember.addQuery('group',assignmentGroup); // query assignement selected group
gmember.addQuery('user', '!=', '');   // check for user
gmember.query();
if(!gmember.next())
{
  gs.addInfoMessage('Please add a group with members'); 
}
current.setAbortAction(true);

View solution in original post

13 REPLIES 13

You need to make script include which client callable. I would suggest to create a new script include that is client callable. PFA Screenshot. 

 

Mehta_0-1679994582937.png

 

PFA Screenshot of the Script include, this will work for your scenario.

Mehta_1-1679994674824.png

 

Code :

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

    getAssignmentGroup: function() {
        if (gs.hasRole('itil') && !gs.hasRole('admin')) {
            return 'type=1cb8ab9bff500200158bffffffffff62';
        }
    },
    type: 'getAssignment'
});

Hi Mehta

 

Now it is working fine and first part is completed. As part of 2nd requirement, if user is selecting any group where no member is part of that group then system should throws a warning message "Please select a valid group which has members" . I have written a BR (before BR) but this is also not working.

(function executeRule(current, previous /*null when async*/) {

var gr = new GlideRecord('task');
gr.addQuery('task', current.sys_id);
gr.query();
while (gr.next()) {
try {
if (gr.assigned_to == '') {

gs.addErrorMessage('Please select a valid group which has members');
current.setAbortAction(true);

}

} catch (e) {
gs.info('Please check the Assigned to');

}
}


})(current, previous);

 

Please help with this last part.

You should create a business rule on incident table and should run on update. the condition should be when assignment group changes and assignment group is not empty. 

 

Below script should satisfied the requirement : 

var assignmentGroup = current.assignment_group; 
//Glide group member table
var gmember = new GlideRecord('sys_user_grmember');
gmember.addQuery('group',assignmentGroup); // query assignement selected group
gmember.addQuery('user', '!=', '');   // check for user
gmember.query();
if(!gmember.next())
{
  gs.addInfoMessage('Please add a group with members'); 
}
current.setAbortAction(true);

HI Mehta

 

Thanks you very much. Now complete development is finished.

Hi Mehta

There is small issue. With the above code when I am trying to submit a ticket I am getting a error message "Invalid insert" and this is happening for all group even if member is part of that group.

Please suggest what is changes required in it.