Groups

Forms Developer Guides Scripting Authorization

The Authorize.group helper checks the current user's group memberships.

Authorize.group(name_or_id...)

Matches any of the groups passed as parameters, either by name or ID.

Authorize.group("Staff Members", "1b85c16e-3164-4254-9419-68e76ed60fa5").then(function() {
  // This callback is only run if the user belongs to either the group named
  // "Staff Members", OR the group with the ID "1b85c16e-3164-4254-9419-68e76ed60fa5"
});

Authorize.group().all(name_or_id...)

Matches all of the groups passed as parameters, either by name or ID.

Authorize.group("Staff Members", "Administrators").then(function() {
  // This callback is only run if the user belongs to both the group named
  // "Staff Members", AND the group named "Administrators"
});

Authorize.group().any(name_or_id...)

Matches any of the groups passed as parameters, either by name or ID. This method is equivalent to calling Authorize.group directly, but can be chained to an all method for more advanced checks.

Authorize.group().any("Staff Members", "Administrators").then(function() {
  // This callback is only run if the user belongs to either the group named
  // "Staff Members", OR the group named "Administrators"
});

Method Chaining

The any and all methods can be chained to build more advanced conditional group checks.

Authorize.group().all("Staff Members").any("Administrators", "Managers").then(function() {
  // This callback is only run if the user belongs to the "Staff Members" group,
  // and either the "Administrators" or "Managers" groups.
});

Promise methods like then can run between chained methods to trigger callbacks before additional checks.

Authorize.group().all("Staff Members").then(function() {
  // This callback is only run if the user belongs to the "Staff Members" group
}).any("Administrators", "Managers").then(function() {
  // This callback is only run if the user belongs to the "Staff Members" group,
  // and either the "Administrators" or "Managers" groups.
});