Hello and welcome! In Rewst 106, we'll complete our workflow and explore how to use sub-workflows and With items in Rewst. Sub-workflows enable us to utilize workflows within other workflows, creating a parent-child relationship. With items is a feature in Rewst that allows actions or workflows to run on all items in a list simultaneously. We'll demonstrate how to leverage these functionalities to manage group memberships efficiently.
Watch the video and follow along with the steps below
Get Credit
To get credit for completing this session offline, please submit this form.
Follow Along
Part 1: Creating a Parent Workflow in Rewst
First, we're going to build a new parent workflow that starts by getting the User from the form.
Step 1: Building the new Parent Workflow
Setting Input Configuration Variables
Create a new workflow named "Add or Remove User from Multiple Groups".
Add Input Configuration variables:
action
user_id
group_ids
Set type to List for group_ids.
Click Submit.
Adding Get User Action
Add a Get User action from the Microsoft Graph category.
Rename the action get_user.
Set the parameter User ID to {{ CTX.user_id }}.
Click the On Success transition.
Create a Data Alias:
Key: target_user
Value: {{ RESULT.result.data.value }}
Part 2: Adding a Sub-Workflow and Utilizing With Items
Next, we're going to add our original workflow as the sub-workflow and modify the form and Form Trigger to take advantage of With items.
Step 2: Adding a Sub-Workflow into the Parent Workflow
Add the Add or Remove Group Membership workflow
Add the Add or Remove from AzureAD Group workflow from the Workflows category.
This is the workflow built in Rewst 105.
ConnectOn Success transition of get_user to workflow_add_or_remove_group_membership.
Rename the sub-workflow to "modify_group_member".
SetWith Items in the Advanced tab to {{ CTX.group_ids }}.
Configure the Parameters of the sub-workflow.
action: {{ CTX.action }}
user_id: {{ CTX.user_id }}
group_id: {{ item() }}
Step 3: Modifying the Form Trigger
Configuring Add or Remove User from AzureAD Group Form
Navigate to Add or Remove from AzureAD Group form.
(Optional): Clone the form, to keep a copy of the form.
Add a Multi-Select Field to the form.
Configure the Multi-Select field:
Field Name: group_ids
Field Label: Groups
Field Description: Select the groups to add to or remove from.
Dynamic Options: Enabled
Workflow Generated: Enabled
Workflow: Option Generator for Groups based on User Membership
Label Field: displayName
Trigger: Option Generator
Workflow Inputs: Note the variable at the end of the name. Check Populate from form field and select the variable that corresponds with each input.
Remove the previous Group field.
Add the Form as a Trigger for the Parent Workflow
Return to the parent workflow.
Add a form trigger to Add or Remove User from Multiple Groups
Name: Form Trigger
Enabled toggled
Trigger Type: Core - Form Submission
Form: Cloned - Add or Remove User from AzureAD Group
Click Submit.
Part 3: Collect the Modification Results and Send Email Notifications
Next, we're going to capture the results and store them in a list in order to send the information via email.
Steps 4: Sending Feedback to the User
Get the Results
Add a noop below modify_group_member.
Rename it "collect_modification_results".
Connect modify_group_member's On Success transition to \collect_modification_results_.
Clickcollect_modification_results's transition.
Create a Data Alias:
key: modification_results
value:
{{
[
modification.result.group_result
for modification in TASKS.modify_group_member.collected_results()
]
}}
Setup Rewst to Email the Results
Add a Core sendmail action below collect_modification_results.
Connectcollect_modification_results's transition to core_sendmail.
Clickcore_sendmail.
Set the Parameters:
Recipient: {{ CTX.user.username }}.
Subject: User {{ CTX.target_user.displayName | d }} Group Modification
Title: User {{ CTX.target_user.displayName | d }} Group Modification
Message:
The group memberships for {{ CTX.target_user.displayName|d }} have been modified:
* {{ CTX.modification_results | join('\n* ') }}
Part 4: Testing the Workflow
Finally, we'll test it all out to see how it works!
Steps 5: Test It
Adding or Removing a User to Multiple Groups
Access the form.
Select a user.
Select Add or Remove.
Select multiple groups.
Confirm that an email is received with the feedback messages.
Conclusion
Thank you for watching! We hope this course helps you effectively utilize sub-workflows and "with items" in Rewst for efficient workflow management. If you have any questions or need further assistance, don't hesitate to reach out. Happy automating!
Additional Resources
For more information about With Items and Sub-Workflows, check out our documentation: