- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 04:33 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 03:38 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 02:12 AM
You need to make script include which client callable. I would suggest to create a new script include that is client callable. PFA Screenshot.
PFA Screenshot of the Script include, this will work for your scenario.
Code :
var getAssignment = Class.create();
getAssignment.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getAssignmentGroup: function() {
if (gs.hasRole('itil') && !gs.hasRole('admin')) {
return 'type=1cb8ab9bff500200158bffffffffff62';
}
},
type: 'getAssignment'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 02:58 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 03:38 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 05:20 AM
HI Mehta
Thanks you very much. Now complete development is finished.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 07:35 AM
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.