Links

106 - Subworkflows and With Items

Introduction

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. Let's dive in and get started!
When you've completed this training, don't forget to get credit!

Watch the video or follow along with the steps below

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
  1. 1.
    Create a new workflow named "Add or Remove User from Multiple Groups".
  2. 2.
    Add Input Configuration variables:
    • action
    • user_id
    • group_ids
  3. 3.
    Set type to List for group_ids.
  4. 4.
    Click Submit.
Adding Get User Action
  1. 1.
    Add a Get User action from the Microsoft Graph category.
  2. 2.
    Rename the action get_user.
  3. 3.
    Set the parameter User ID to {{ CTX.user_id }}.
  4. 4.
    Click the On Success transition.
  5. 5.
    Create a Data Alias:
    • Key: target_user
    • Value: {{ RESULT.result.data.value }}

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 Subworkflow into the Parent Workflow
Add the Add or Remove Group Membership workflow
  1. 1.
    Add the Add or Remove Group Membership workflow from the Workflows category.
    1. 1.
      . This is the workflow built in Rewst 105.
  2. 2.
    Connect On Success transition of get_user to workflow_add_or_remove_group_membership.
  3. 3.
    Rename the sub-workflow to "modify_group_member".
  4. 4.
    Set With Items in the Advanced tab to {{ CTX.group_ids }}.
  5. 5.
    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
  1. 1.
    Navigate to Add or Remove from AzureAD Group form.
    • (Optional): Clone the form, to keep a copy of the form.
  2. 2.
    Add a Multi-Select Field to the form.
  3. 3.
    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.
  4. 4.
    Remove the previous Group field.
Add the Form as a Trigger for the Parent Workflow
  1. 1.
    Return to the parent workflow.
  2. 2.
    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
  3. 3.
    Click Submit.

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
  1. 1.
    Add a noop below modify_group_member.
  2. 2.
    Rename it "collect_modification_results".
  3. 3.
    Connect modify_group_member's On Success transition to \collect_modification_results_.
  4. 4.
    Click collect_modification_results's transition.
  5. 5.
    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
  1. 1.
    Add a Core sendmail action below collect_modification_results.
  2. 2.
    Connect collect_modification_results's transition to core_sendmail.
  3. 3.
    Click core_sendmail.
  4. 4.
    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* ') }}

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
  1. 1.
    Access the form.
  2. 2.
    Select a user.
  3. 3.
    Select Add or Remove.
  4. 4.
    Select multiple groups.
  5. 5.
    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, please don't hesitate to reach out. Happy automating!

Get Credit

To get credit for completing this session offline, please submit this form.

Additional Resources

For more information about With Items and Sub-Workflows, check out our documentation:

Need more guidance?

Sign up for our LIVE training sessions below!
Last modified 3mo ago