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

Community site session details

Session Id :
Power Automate - Building Flows
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,

I have the same question (0)
  • Verified answer
    lbendlin Profile Picture
    8,474 Super User 2025 Season 2 on at
    Re: Assistance Required: Dynamically Adding an "ID" Column to an Array

    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,474 Super User 2025 Season 2 on at
    Re: Assistance Required: Dynamically Adding an "ID" Column to an Array

    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

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 532 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 461 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 256

Last 30 days Overall leaderboard