web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Assistance Required: D...
Power Automate
Answered

Assistance Required: Dynamically Adding an "ID" Column to an Array

(0) ShareShare
ReportReport
Posted on by
Hello Guy,
 
I hope this message finds you well. I am currently working on a project that involves manipulating a data array obtained from a "Select columns" action connect to a Sharepoint List. 
 
FarmaVIP_0-1708896049402.png
 
The array represents a collection of records with various details. Here is the current structure of my array:

 

{
    "body": [
        {
            "Nome do Utente""teste56",
            "Data da Venda""2024-02-01",
            "Nº Receita""",
            "Valor""56,00",
            "Observações""sdasdddddddds",
            "Assistente Social""Joao "
        },
        {
            "Nome do Utente""teste67",
            "Data da Venda""2024-02-01",
            "Nº Receita""",
            "Valor""245,00",
            "Observações""Foi ali e voltou",
            "Assistente Social""teste67"
        },
        {
            "Nome do Utente""SSS",
            "Data da Venda""2024-02-01",
            "Nº Receita""",
            "Valor""150,00",
            "Observações""",
            "Assistente Social""Ricardo"
        }
    ]
}
 
I am looking to enhance this array by dynamically inserting an additional column named "ID" for each record. The "ID" values should start from 1 and increment sequentially up for the subsequent records. The desired outcome is to have each item in the array uniquely identified by an incremental ID, as shown in the example below:
 
{
    "body": [
        {
            "ID":1
            "Nome do Utente""teste56",
            "Data da Venda""2024-02-01",
            "Nº Receita""",
            "Valor""56,00",
            "Observações""sdasdddddddds",
            "Assistente Social""Joao "
        },
        {
             "ID":2
            "Nome do Utente""teste67",
            "Data da Venda""2024-02-01",
            "Nº Receita""",
            "Valor""245,00",
            "Observações""Foi ali e voltou",
            "Assistente Social""teste67"
        },
        {
             "ID":3
            "Nome do Utente""SSS",
            "Data da Venda""2024-02-01",
            "Nº Receita""",
            "Valor""150,00",
            "Observações""",
            "Assistente Social""Ricardo"
     }
    ]
}
 
 

I envision utilizing a variable within a loop to achieve this, iterating over the number of items in my SharePoint list from which the original array is derived. However, I am uncertain about the most efficient way to merge these components successfully.

Could anyone provide guidance or share insights on how best to implement this functionality? Any suggestions or examples of similar implementations would be greatly appreciated.

Thank you in advance for your time and assistance.

Best regards,

Categories:
I have the same question (0)
  • Verified answer
    lbendlin Profile Picture
    8,551 Super User 2026 Season 1 on at

    This may not be the most efficient way but it seems to work

     

    lbendlin_0-1708911893662.pnglbendlin_1-1708911925786.png

    You initialize the Output variable as an empty array, and the Index variable as an Integer with 0  (or 1)

    Then you iterate over the elements of the input array and use addProperty() to add the index and push the result into the Output Array.  After that you increment the index variable.

     

    lbendlin_2-1708912034867.png

     

  • Verified answer
    lbendlin Profile Picture
    8,551 Super User 2026 Season 1 on at

    Found a slightly simpler way that doesn't require the Index variable

    lbendlin_2-1708915009584.png

     

     

    lbendlin_1-1708914919663.png

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 112 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 52

#3
Ellis Karim Profile Picture

Ellis Karim 51 Super User 2026 Season 1

Last 30 days Overall leaderboard