Links

106 - Subworkflows and With Items

Sign up for our LIVE training sessions below!

Subworkflows and With Items: Hands-on Exercises

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 }}
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 subworkflow 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.
    1. 1.
      (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.
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* ') }}
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.

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: