104 - Options Generators & Generic API Requests
Sign up for our LIVE training sessions below!
These steps assume you have completed the full steps from Rewst 102 You can find the instructions to make this form on the Rewst 102 Page.
Open the Form
- 1.Go to Automations → Forms in the menu.
- 2.Search for the Add or Remove from AzureAD Group Form.
- 3.Click on the Form to Open it.
Re-order the Form
- 1.Drag and Drop the Add or Remove Field above Group.
- 2.Click the Save button at the top right of the form builder.
- 3.Click Submit on the pop-up to confirm.
Create a New Workflow
- 1.Go to Automations → Workflows in the menu.
- You can open this in a new tab to make it easier.
- 2.Click Create at the top right to add a new Workflow.
- 3.Type Option Generator for Groups based on User Membership for the name.
- 4.Click Submit.
Add Output Configuration in Workflow Variables
- 1.Click on Configure Workflow Variables (The Pencil icon) at the top right of the Menu.
- 2.Choose Option Generator for the Workflow Type dropdown.
- 3.Click on the Add (+) button next to Output Configuration at the bottom.
- 4.Type options for the Field Name.
- 5.Click Submit.
Add Input Configuration Variables
- 1.Click on the Add (+) button next to Input Configuration.
- 2.Type action for the name.
- 3.Click Required.
- 4.Click on the Add (+) button next to Input Configuration again.
- 5.Type user_id for the name.
- 6.Click Required.
- 7.Click Submit.
Add a Core Noop Action to the Canvas
- 1.Drag and Drop the noop action to the Workflow Canvas.
- You can find this in the Core section or by searching.
- 2.Click on the noop to open the Details menu.
- 3.Click the edit button next to core_noop.
- 4.Rename the action to add_or_remove.
- 5.Click Advanced.
- 6.Choose the Follow First Transition Mode.
Create a Transition for Adding a User
- 1.Click on the default On Success transition on the add_or_remove noop.
- 2.Type Add for the Custom Label.
- 3.Click the Custom Condition button from the Condition options.
- 4.Click the Source button next to the Custom Condition field.
- 5.Type
{{ CTX.action == "add" }}
in the editor. - 6.Close the editor.
Create a Transition for Removing a User
- 1.Click the Add (+) button next to the Add transition.
- 2.Type Remove for the Custom Label.
- 3.Click the Custom Condition button from the Condition options.
- 4.Click the Source button next to the Custom Condition field.
- 5.Type
{{ CTX.action == "remove" }}
in the editor.
Add a Graph API Request action to List Member Groups
- 1.Drag and Drop the Graph API Request action to the Workflow Canvas.
- You can find this in the Microsoft Graph section or by searching.
- 2.Click on the new action to open the Details menu.
- 3.Click the edit button next to the name.
- 4.Rename the action to list_user_groups.
Add API Information to the List User Groups Action
It is recommended that you reference the API Docs These docs are references in this portion of the training
- 1.Click the Source button next to the Endpoint field.
- 2.Add
/users/{id | userPrincipalName}/memberOf
from the API docs to the editor. - 3.Replace
{id | userPrincipalName}
with{{ CTX.user_id }}
so it looks like the following:/users/{{ CTX.user_id }}/memberOf - 4.Close the editor.
- 5.Click and Drag the transition from the add_or_remove action to the list_user_groups action.
- To do this, you will need to hover over the circle under the Remove section of the action.
Add a Graph List Groups action to List All Groups
- 1.Drag and Drop the List Groups action to the Workflow Canvas.
- You can find this in the Microsoft Graph section or by searching.
- 2.Click on the action to open the Details menu.
- 3.Click the edit button next to name.
- 4.Rename the action to list_all_groups.
Add a Data Alias to the List All Groups action
- 1.Click on the On Success transition.
- 2.Click on the Add (+) button next to Data Aliases.
- 3.Type all_groups as the key.
- 4.Open the Source editor.
- 5.Add the following to the editor:
{{ RESULT.result.data.value }}
- 6.Close the editor.
- 7.Click and Drag the transition from the add_or_remove action to the list_all_groups action.
- To do this, you will need to hover over the circle under the Add section of the action.
Add a Data Alias to the List User Groups action
- 1.Click on the On Success transition of list_user_groups.
- 2.Click on the Add (+) button next to Data Aliases.
- 3.Type group_list as the key.
- 4.Open the Source editor.
- 5.Add the following to the editor:{{ RESULT.result.data.value }}
- 6.Close the editor.
Copy the List User Groups Action
- 1.Click on the options menu next to the list_user_groups action.
- 2.Click Create Copy.
- 3.Move it on the Canvas under the list_all_groups action.
- 4.Drag the Transition from list_all_groups to the list_user_groups copy.
- 5.Click on the On Success Transition for the new copy.
- 6.Change the Data Alias from group_list to user_groups.
Add a Final Noop to Build the Group List
- 1.Add a core_noop action under the list_user_groups action.
- 2.Click on the action to open the Details menu.
- 3.Change the name to build_group_list.
- 4.Click the On Success Transition.
- 5.Click on the Add (+) button next to Data Aliases.
- 6.Type group_list as the key.
- 7.Open the Source editor.
- 8.Add the following Jinja to the editor:{{[groupfor group in CTX.all_groupsif group.id not in [user_group.idfor user_group in CTX.user_groups]]}}
- 9.Close the editor.
Add the Final Transition
- 1.Drag the Transition from list_user_groups to the build_group_list copy.
- 2.Click Publish.
- 3.Click Submit.
Open the Workflow Variables
- 1.Click on Configure Workflow Variables (The Pencil icon) at the top right of the Menu.
- 2.Open the source editor next to the options Output Configuration.
- 3.Type the following:{{ CTX.group_list }}
- 4.Click Submit.
Add and Configure the Trigger
- 1.Click Add Trigger in the top menu.
- 2.Type Option Generator for the Name.
- 3.Click the slider next to Enabled.
- 4.Choose Core - Always Pass Trigger Type.
- 5.Click the slider next to All current and future managed organizations.
- 6.Click the Add (+) button next to Integration Overrides.
- 7.Choose Microsoft Graph for the Integration dropdown.
- 8.Click Submit.
- You may need to Click Cancel after to close it.
- 9.Click Publish at the top right of the workflow.
- 10.Click Submit.
Change the Group field to Workflow Generated
- 1.Go to Automations → Forms in the menu.
- If you already have another tab open, go back to your form.
- 2.Open the Add or Remove from AzureAD Group Form.
- 3.Click on the Group field.
- 4.Click the slider under Workflow Generated.
Configure the Details of the Workflow Generated Field
- 1.Select the Option Generator for Groups based on User Membership Workflow from the dropdown.
- 1.Refresh the page if the workflow does not appear.
- 2.Replace the Label Field default with displayName.
- 3.Choose Option Generator for the Trigger.
- 4.Click Populate from form field under the
schema.enumSourceWorkflow.input.action
field. - 5.Choose
action
from the dropdown. - 6.Click Populate from form field under the
schema.enumSourceWorkflow.input.user_id
field. - 7.Choose
user_id
from the dropdown. - 8.Click Save.
- 9.Click Submit.
Run the Form to Pull the Options Generator
- 1.Click on View Usages at the top right.
- 2.Click on the View Direct URLs.
- 3.Click on the link.
⚠️ You will not see the link if you haven't completed Rewst 102 The link shows up because the Workflow built in 102 has the Form set as a trigger. You can find the instructions to make this workflow on the Rewst 102 Page
For more information on using Options Generators, Generic API Requests, List Comprehension, and more, check out our documentation: