Skip to main content
March 16, 2023
Question

To check if a group exists in environment.

  • March 16, 2023
  • 3 replies
  • 0 views

I have a use case to check if a group already exists. And if not, we should create the group.

Is there any way to check a group exists in an environment already.

3 replies

mikes0011
Brainy
March 16, 2023

By what metric would you judge whether a group "already exists"?  If you're just going by Group Name, you can always check the "get group by name" function and see if there are any results.

The Expression Guru
March 16, 2023

I have a scenario to check a group exists by it's name without group ID..

I'm having a text value and want to check if a group name similar to a text exists or not.

i.e., Suppose, I have a country Code of IN for the country INDIA, Now, I want to check if any group in name of eg:"IN Users"(text value which is to be created as a group) is present in the environment.. If it is not present, I will go ahead and create a group named "IN Users".

March 16, 2023

Hi,

As Mike mentioned you can use a!groupsByName() to check if group with that name exist or not, like

if(
  a!isNullOrEmpty(a!groupsByName("IN Users")),
  "Create group",
  "Never mind, don't create"
)