A Logic App workflow that uses Filter array, Select and Join actions

Create a Logic App workflow that uses a Recurrence trigger, initializes a variable with JSON data, filters the array, uses Select and Join actions, and performs additional operations.

Scenario

  1. The workflow triggers on a schedule (Recurrence trigger).
  2. Initialize a variable with an array of JSON objects.
  3. Filter the array based on a condition.
  4. Use the Select action to transform the filtered array.
  5. Use the Join action to concatenate the transformed data.
  6. Send the result in an email or save it to a file.

Step-by-Step Workflow

Step 1: Create a Logic App

  1. Go to the Azure portal.
  2. Click on Create a resource > Integration > Logic App.
  3. Provide a name, subscription, resource group, and location for your Logic App.
  4. Click Review + create and then Create.

Step 2: Add a Recurrence Trigger

  1. Open your Logic App in the designer.
  2. Search for the Recurrence trigger and add it.
  3. Configure the recurrence interval (e.g., every day, every hour, etc.).
    • Interval: 1
    • Frequency: Day (or Hour, depending on your requirement)

Step 3: Initialize a Variable with JSON Data

  1. Add a new action after the Recurrence trigger.
  2. Search for Initialize variable and add it.
  3. Configure the variable:
    • NamejsonData
    • TypeArray
    • Value: Paste your JSON data as an array. For example:
      [
        { "id": 1, "name": "John Doe", "email": "john@example.com", "age": 30 },
        { "id": 2, "name": "Jane Smith", "email": "jane@example.com", "age": 25 },
        { "id": 3, "name": "Alice Johnson", "email": "alice@example.com", "age": 35 }
      ]

Step 4: Filter the Array

  1. Add a new action after the Initialize variable action.
  2. Search for Filter array and add it.
  3. In the From field, select the jsonData variable.
  4. Set the filter condition. For example, filter objects where age is greater than 30:
    • Conditionitem()?['age'] > 30
    • This will filter the array to include only objects where the age field is greater than 30.

Step 5: Use the Select Action

  1. Add a new action after the Filter array action.
  2. Search for Select and add it.
  3. In the From field, select the output of the Filter array action.
  4. Use the Map section to transform the filtered array. For example:
      • Keyname
      • Valueitem()?['name']
      • Keyemail
      • Valueitem()?['email']
    • This will create an array of objects with only the name and email fields.

Step 6: Use the Join Action

  1. Add a new action after the Select action.
  2. Search for Join and add it.
  3. In the From field, select the output of the Select action.
  4. Specify the Join with delimiter. For example, use a comma (,):
    • This will concatenate the values into a single string.

Step 7: Send an Email with the Result

  1. Add a new action after the Join action.
  2. Search for Gmail (or your email provider) and select Send email (V2).
  3. Connect to your email account.
  4. Fill in the email details:
    • To: Recipient email address
    • SubjectFiltered and Transformed Data
    • Body: Insert the output of the Join action. For example:
      Here is the filtered and transformed data:
      @{body('Join')}

Here's how Logic App should look:

estudy247-la-test-dataops-12

Testing the Workflow

  1. Save and run the Logic App.
  2. The workflow will:
    • Trigger based on the recurrence schedule.
    • Initialize the JSON data.
    • Filter the array.
    • Transform the filtered array using Select.
    • Concatenate the transformed data using Join.
    • Send an email with the result.

Sample Output

estudy247-la-test-dataops-output

You can download the logic app template from the estudy247 GitHub repository – la-test-dataops-12

Post a comment

Leave a Comment

Scroll to Top