106 - Subworkflows and With Items
Sign up for our LIVE training sessions below!
Setting Input Configuration Variables
- 1.Create a new workflow named "Add or Remove User from Multiple Groups".
- 2.Add Input Configuration variables:
- action
- user_id
- group_ids
- 3.Set type to List for group_ids.
- 4.Click Submit.
Adding _Get User_** Action**
- 1.Add a Get User action from the Microsoft Graph category.
- 2.Rename the action get_user.
- 3.Set the parameter User ID to
{{ CTX.user_id }}
. - 4.Click the On Success transition.
- 5.Create a Data Alias:
- Key:
target_user
- Value:
({{ RESULT.result.data.value }}
Add the _Add or Remove Group Membership_** workflow**
- 1.Add the Add or Remove Group Membership workflow from the Workflows category.
- 1.. This is the workflow built in Rewst 105.
- 2.Connect On Success transition of get_user to workflow_add_or_remove_group_membership.
- 3.Rename the subworkflow to "modify_group_member".
- 4.Set With Items in the Advanced tab to
({{ CTX.group_ids }})
. - 5.Configure the Parameters of the sub-workflow.
- action:
{{ CTX.action }}
- user_id:
{{ CTX.user_id }}
- group_id:
{{ item() }}
Configuring _Add or Remove User from AzureAD Group Form_
- 1.Navigate to Add or Remove from AzureAD Group form.
- 1.(Optional): Clone the form, to keep a copy of the form.
- 2.Add a Multi-Select Field to the form.
- 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.Remove the previous Group field.
Add the Form as a Trigger for the Parent Workflow
- 1.Return to the parent workflow.
- 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.Click Submit.
Get the Results
- 1.Add a noop below modify_group_member.
- 2.Rename it "collect_modification_results".
- 3.Connect modify_group_member's On Success transition to \collect_modification_results_.
- 4.Click collect_modification_results's transition.
- 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.Add a Core sendmail action below collect_modification_results.
- 2.Connect collect_modification_results's transition to core_sendmail.
- 3.Click core_sendmail.
- 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* ') }}
For more information about With Items and Sub-Workflows, check out our documentation: