By usin query Business rule such that if logged in user is part of Service desk or admin then only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 09:40 PM
Hi,
Write a query Business rule such that if logged in user is part of Service desk or admin then only can see the incidents assigned to Service Desk group.
Please help me out with the Business rule in step by step manner.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2025 12:12 AM
Hello @kranthi2
In Advanced tab section under script field populate below code:
(function executeRule(current, previous /*null when async*/ ) {
// Get the current user's ID
var userID = gs.getUserID();
var isServiceDeskMember = false;
// Check if the user is a member of the Service Desk group
var groupMemberGR = new GlideRecord('sys_user_grmember');
groupMemberGR.addQuery('group.name', 'Service Desk');
groupMemberGR.addQuery('user', userID);
groupMemberGR.query();
if (groupMemberGR.next()) {
isServiceDeskMember = true;
}
// Check if the user is part of Service Desk or Admin group
if (!isServiceDeskMember && !gs.hasRole('admin')) {
// Restrict visibility to incidents assigned to Service Desk group
current.addQuery('assignment_group', '!=', 'Service Desk Group Sys ID');
}
})(current, previous);
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2025 03:12 AM
Hi @kranthi2 ,
you can use this
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya