- 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 07:51 AM
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.query();
if(!gmember.next())
{
gs.addInfoMessage('Please add a group with members');
current.setAbortAction(true);
}
This is an updated script that actually I am running on a production instance. If still it gives you invalid insert please provide me with screenshot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 08:11 AM
Here group is "Business Application Registration Approval Group" type as itil but no member added to it.
Here group is "CAB Approval" type as itil and member added to it.
for both the case "invalid insert" is coming.
Business rule
(function executeRule(current, previous /*null when async*/) {
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);
})(current, previous);
= = = = = = = = = = = = = = = = = = = = =
Business rule
(function executeRule(current, previous /*null when async*/) {
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);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 08:18 AM
Please use this code :
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.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 09:04 AM
HI Mehta
I found root cause. Whatever code you have given is correct only, Just the abort action was not correct place. I modified it and its started working now.