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!

Add Actions to the Workflow

Step 1: Add a noop action
  1. Add a noop to the workflow canvas.

  2. Follow the instructions in: Adding Actions to the "Add or Remove User - Microsoft Group" Workflowto configure the noop.

    • Alternatively, you can copy the noop from the "Add or Remove User - Microsoft Group" workflow and paste it into this Option Generator.

  3. Search "graph list groups" in the search bar.

  4. Add List Groups action under the "Add to Group" transition of the add_or_remove noop.

  5. Connect the transition from Add to Group to the List Groups action

  6. Search "graph api" in the search bar.

  7. Add "Graph API Request" below "remove from group" transition.

  8. Rename "Graph API Request" to "list_user_groups"

Step 2: Adding Graph Actions
  1. Search for "graph list groups" in the search bar.

  2. Add List Groups below the "Add to Group" transition of the add_or_remove noop.

  3. Connect the transition from Add to Group to the List Groups action

  4. Search "graph api" in the search bar.

  5. Add "Graph API Request" under the "Remove from Group" transition of the noop.

  6. Rename the "Graph API Request" to "list_user_groups".

  7. Select the Jinja Editor icon for the Endpoint field in "list_user_groups"

    • Add /users/{{ CTX.user_id }}/memberOf

  8. Close the Jinja Editor.

  9. Add a data alias in the transition of the "list_user_groups" action

    • Key: group_list

    • Value: {{ RESULT.result.data.value }}

  10. Rename "microsoft_graph_list_groups" to "list_all_groups"

  11. Add a data alias in the transition of "list_all_groups"

    • Key: all_groups

    • Value: {{ RESULT.result.data.value }}

  12. Copy the "list_user_groups" API request action and move it below "list_all_groups"

  13. Connect the transition of "list_all_groups" to "list_user_groups" from the previous step

Step 3: Adding Jinja Logic
  1. Add a noop below the copied "list_user_groups" and connect the transition from "list_user_groups"

  2. Rename the noop "build_group_list"

  3. 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
          ]
        ]
      -}} 
      
  1. Click Publish 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.

  • Review How to Reference Data with Variables to store objects from the action into Data Aliases.

Last updated