Restrict to add group to user if the group contains itil or admin to contact(class=contact) users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2024 09:39 AM
If I try to add a group(from Groups related list) in User profile(if the user class is 'contact') I should verify if the group has a roles itil or admin. if the group contains I should abort the action or should not allow to add that group. How to achieve it?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2024 09:46 AM - edited ‎04-17-2024 09:46 AM
Hi,
You could create an on insert, before business rule on the group membership table and within that, query the group has roles table to see if they have one of those two roles, and if so, abort the action:
gs.addErrorMessage("This group has restricted roles and you're unable to add members");
current.setAbortAction(true);
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2024 10:23 AM
Hi Allen, Thank you for your response. Yes, I am able to abort the action but the error message is not showing.
I still see the message on the form as 'Job to add or remove roles from users of group has been queued'. But our message should be display. What was wrong with it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2024 10:27 AM
Please help me with script, how to query the group has roles table to see if they have one of the those roles?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2024 09:57 AM
Hi @Sarah Bouil
Create an insert Business Rule on sys_user_grmember table with following conditions by using show related fields-
and set Abort actions to true-
Please mark my answer helpful and correct.
Regards,
Amit