Modify elements of an object in an array in Power Automate(Select Operation)

Introduction

This blog explains how to use the Select Data Operation in Power Automate (MS Flow).

Using ‘Select’ you can add, remove, or rename elements in each object in an array.

Use Case: In my example, I am using a sample array as shown below. We will perform the actions given below on the elements:

  • Rename “FName” to “FirstName” and “LName” to “LastName”
  • Add New element “FullName”: “FirstName” + “LastName”
  • Remove “City” and “Country” element
  • Add New element “Address”: “City” , “Country”

Array:

[
    {
        "FName": "Vaishali",
        "LName": "Vyas",
        "City": "Mumbai",
        "Country": "India",
        "Email": "abc@sample.com",
        "Preferred Language": [
            "English",
            "Hindi"
        ],
        "Employee Type": "Full Time",
        "Phone": "808080808080"
    }
]

Steps to be followed:

  1. Add “+New step”
  1. Search for “Select” Data Operation and select it.
  1. Enter your array in “From”
  • Map elements based on your requirements.

For Example, Renaming “FName” to “FirstName”.

  • Enter “FirstName” in Key and pass its value from the Dynamic Content.
  • Repeat this for “LastName”

Adding New Element “FullName” and “Address”

We don’t want to make any changes to the Email, Phone, and Preferred language element so we will add it as it is.

Below is the select query after adding and modifying all the elements

Add compose action to see the output of Select Operation.

Entire Flow:

Running the Flow:

Leave a Reply

Your email address will not be published. Required fields are marked *