Using Jinja in Data Aliases and Creating an API Request Action
Use a data alias to store the "options" for a form field and accurately map those options in workflow output configuration.
Module Overview
💡 In this Options Generator workflow, you'll use data aliases to manage how individual actions store data from integrations. You'll also implement custom API requests when Rewst doesn't offer a built-in action, leveraging Microsoft Graph API documentation. Two key skills, one workflow—like finding that double-yolk at breakfast!
Video (12:52 Minutes)
Remember, everything we’re doing is to output data to the group field connected to this Option Generator. That's the ultimate goal of this workflow!
Alternatively, you can copy the noop from the "Add or Remove User - Microsoft Group" workflow and paste it into this Option Generator.
Search "graph list groups" in the search bar.
Add List Groups action under the "Add to Group" transition of the add_or_remove noop.
Connect the transition from Add to Group to the List Groups action
Search "graph api" in the search bar.
Add "Graph API Request" below "remove from group" transition.
Rename "Graph API Request" to "list_user_groups"
Step 2: Adding Graph Actions
Search for "graph list groups" in the search bar.
Add List Groups below the "Add to Group" transition of the add_or_remove noop.
Connect the transition from Add to Group to the List Groups action
Search "graph api" in the search bar.
Add "Graph API Request" under the "Remove from Group" transition of the noop.
Rename the "Graph API Request" to "list_user_groups".
Select the Jinja Editor icon for the Endpoint field in "list_user_groups"
Add/users/{{ CTX.user_id }}/memberOf
Close the Jinja Editor.
Add a data alias in the transition of the "list_user_groups" action
Key: group_list
Value: {{ RESULT.result.data.value }}
Rename "microsoft_graph_list_groups" to "list_all_groups"
Add a data alias in the transition of "list_all_groups"
Key: all_groups
Value: {{ RESULT.result.data.value }}
Copy the "list_user_groups" API request action and move it below "list_all_groups"
Connect the transition of "list_all_groups" to "list_user_groups" from the previous step
Step 3: Adding Jinja Logic
Add a noop below the copied "list_user_groups" and connect the transition from "list_user_groups"
Rename the noop "build_group_list"
Create a data alias in "build_group_list"
Key: group_list
Value
{{-
[
group
for group in CTX.all_groups
if group.id not in
[
user_group.id
for user_group in CTX.user_groups
]
]
-}}
ClickPublish to save the workflow.
Action Item
Add and configure a new Generic API Action to execute specific functionality based on the API documentation. Ensure the API endpoint, method, headers, and parameters are set according to the documentation for proper integration.