Restrict to add group to user if the group contains itil or admin to contact(class=contact) users

Sarah Bouil
Tera Expert

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?

7 REPLIES 7

Allen Andreas
Administrator
Administrator

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!

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?

Please help me with script, how to query the group has roles table to see if they have one of the those roles?

Amit Pandey
Kilo Sage

Hi @Sarah Bouil 

 

Create an insert Business Rule on sys_user_grmember table with following conditions by using show related fields-

 

AmitPandey_0-1713372981377.png

 

and set Abort actions to true-

 

AmitPandey_1-1713373022595.png

 

Please mark my answer helpful and correct.

 

Regards,

Amit