Subworkflow: Check a User's Group Memberships to Proceed in a Workflow Crate
What does the Subworkflow: Check a User's Group Memberships to Proceed in a Workflow Crate do?
Use this subworkflow in your workflows and option generators to check to see if a user is a member of one of a list of provided group. This is useful for form-triggered workflows where you may wish to limit the functionality based on a form submitter's role.
How the Crate works
The Crate uses the Microsoft Graph API Request action to get all groups a user belongs to.
Makes a GET request to the Microsoft Graph API
The response will include all groups the user is a member of
Checks if your target group is in the returned list
Workflow breakdown
The workflow begins with the microsoft_graph_list_groups task, which executes the List Groups action to search for Azure AD groups that match the provided group names from the input.
The microsoft_graph_list_groups task uses a filter to find groups where the display name equals any of the group names provided in the input, selecting only the id and displayName fields for efficiency.
If the List Groups action succeeds and returns matching groups, the workflow transitions to the make_group_id_list task, which executes the noop action to create a list of group IDs from the search results.
The make_group_id_list task publishes a group_id_list variable containing the extracted group IDs and then transitions to the check_member_groups task.
The check_member_groups task executes the Graph API Request action to call the Microsoft Graph checkMemberGroups endpoint, passing the username and the list of group IDs to determine if the user is a member of any of those groups.
If the check_member_groups task succeeds, it publishes two key variables: member_group_ids containing the group IDs the user belongs to, and user_in_group set to true or false based on whether any group membership was found, then transitions to the checks_successful task.
The checks_successful task executes the noop action and serves as the successful completion point of the workflow.
If any task fails or if no matching groups are found in step 2, the workflow transitions to the errors_in_processing task, which executes the noop action and publishes any accumulated errors to the workflow output.
The workflow concludes by outputting three values: user_in_group indicating membership status, member_group_ids containing the specific group IDs the user belongs to, and errors containing any error messages encountered during processing.
Crate prerequisite
The Microsoft Cloud integration bundle, which contains our Microsoft Graph integration, must successfully be installed before unpacking this Crate.
Example Jinja template for checking membership
Unpack the Subworkflow: Check a User's Group Memberships to Proceed in a Workflow Crate
Navigate to Crates > Crate Marketplace in the left side menu Rewst platform.
Search for
Sub-workflow: Check a User's Group Memberships to Proceed in a Workflow.
Click on the Crate tile to begin unpacking.
Click Unpack Crate.
Click Continue.
Enter Time Saved under Crate Configuration.
Click Unpack.
Use the subworkflow
Navigate to Automations > Workflows in the left side menu of your Rewst platform.
Click into the workflow where you would like to use the subworkflow, or create a new workflow.
Search in your actions list for
Check if a User is in an AzureAD Group.
Click and drag the action to the Workflow Builder canvas.
Enter the required information into the following fields of the task's configuration menu:
groups: the name or ID of AzureAD Groups to check the user's membership against
username: use CTX.username to capture the form submitter

Last updated
Was this helpful?

