How to restrict to add users in a group when count will be more than 50 by system property

Amol Pawar
Tera Guru

Hi All,

I need help with the below scenario:

 

We have created a group. When someone raises a request from a record producer, we add that user to that group which has a itil role. We want to restrict adding users to that group when the group members count is more than 50.

How can we achieve this?

The requirement is that achieve this by a system property, but let me know if is there any way we can do this.

 

Thanks in advance,

Amol

6 REPLIES 6

Hi @Amol Pawar 

try @Anil Lande 's solution which is only possibility on given scenario.

Basically in this case you dont need BR but instead same logic can be added in Run script as provided earlier.

I believe you already managed to check and restrict the user to be added in respective group now its just matter of sending/not sending the notification to user which is next activity.

So when you are restricting the user to be added, there you can set workflow scratch pad variable to true/false and then use this under If activity before sending email to user.

By this way you can control email sending activity.

 

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

Harish Bainsla
Kilo Patron
Kilo Patron

Write Business Rule 

if (current.group.toString() == targetGroupId) {
var memberCount = new GlideAggregate("sys_user_grmember");
memberCount.addQuery("group", targetGroupId);
memberCount.addAggregate("COUNT");
memberCount.query();
if (memberCount.next()) {
var count = memberCount.getAggregate("COUNT");
if (count >= 50) {
gs.addErrorMessage("The group already has 50 or more members. Cannot add more users.");
current.setAbortAction(true);
}
}
}