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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / use values of objects ...
Power Automate
Unanswered

use values of objects within an array to create item in sharepoint list

(0) ShareShare
ReportReport
Posted on by 8

i have an array with multiple object. Each object contains 3 values separated by a komma (,). a number, a displayname and a department. each object of the array must be imported in the sharepoint list with three columns (nr, displayname and department) in a new row. So, if the array has 4 obects, the list must be append with 4 new rows and ach row must contain the three corresponding values. 

Categories:
I have the same question (0)
  • grantjenkins Profile Picture
    11,063 Moderator on at

    That's some strange JSON you have - values are the field names. Is this array of objects something you create yourself from some other data within the flow, or is it the data that comes from somewhere and you have to use it as it is?

  • Verified answer
    Ellis Karim Profile Picture
    11,681 Super User 2025 Season 2 on at

    Hi @StijnVerbeeck ,

     

    If I have understood the question correctly, you want to do the following: create a new SharePoint item for each JSON object in an array.

     

    For example

    Snag_7b6155b.png

     

    Here is one method you can use to achieve this:

     

    A variable containing the data:

    Snag_7b836c4.png

    We can use a Select action to transform the data into a new JSON array so that the properties are clear and easy to reference:

    Snag_7bd0fbb.png

    Snag_7bee69e.png

    The expressions used in the Select action are:

    nr:
    json(concat('[',replace(slice(string(item()),1,-1),':""',''),']'))?[0]
    
    displayname:
    json(concat('[',replace(slice(string(item()),1,-1),':""',''),']'))?[1]
    
    department: 
    json(concat('[',replace(slice(string(item()),1,-1),':""',''),']'))?[2]

     

    An Apply to each loop is then used to create new items in the SharePoint list using the Output of the Select action:

    Snag_7cb1d54.png

    Snag_7c4c81c.png

     

    The expressions used in the Create item action are:

    items('Apply_to_each')?['nr']
    
    items('Apply_to_each')?['displayname']
    
    items('Apply_to_each')?['department']

     

    See: 📝Short Notes: Illustrating the Item() and Items(‘Apply_to_each’) function in Power Automate

     

    Ellis
    ____________________________________
    If I have answered your question, please mark the post as ☑️ Solved.
    If you like my response, please give it a Thumbs Up.
    My Blog Site

  • StijnVerbeeck Profile Picture
    8 on at

    That works pretty well! Thank you @ekarim2020 

  • StijnVerbeeck Profile Picture
    8 on at

    The "strange" array i have is a variabele array C. I compare two arrays A and B and the json objects that don't exists in array B are appended in the variabele array C. This array C is the source creating new items.

    Array A is a http requets for group members in Azure followed by a "parse json  and a select to just keep the needed fields. 

    Array B is the result of "get items" from the sharepoint list also followed by a select.

    I suppose there are more elegant ways to achieve a sync between group members ad a sharepoint list, but i'm learing. 

  • grantjenkins Profile Picture
    11,063 Moderator on at

    @StijnVerbeeck Are you able to show the flow and how it creates your array? I think if you fix that so it stores the JSON property/values correctly, then you would end up with a much cleaner flow.

  • StijnVerbeeck Profile Picture
    8 on at

    i start with a http request followed by parse json to remove headers from the request  and just keeping the body. 

    http-request and parse json.jpg

    then i use a select and now i see that is where the fieldnames disappear. I used the select action cause i found it in other solutions for filtering and comparing two arrays and because my fieldnames (in case columnnames) are different (id and nr, displayname and leerling, department and school). 

    select json.png

     

    the same steps i do for the get items for the list 

    select get items.png

     

    in the end i apply to each for comparing the values of the select (all items of the group members). If an item of the list not belongs to the current item, i append that current item to the third array (my variable array)

    StijnVerbeeck_0-1677429720041.png

    on the" if-yes"side i have now an array with items that are group members (http request) that are not in my sharepoint list. And that's where i start begin to ask for help. 
    next goal: on the "no-side" of the condition update the items in the list that already excist but where the department has changed. 

  • grantjenkins Profile Picture
    11,063 Moderator on at

    For your Select 2, you should add the values on the Right, and the property names on the Left. See example below. This would avoid having to go through trying to convert everything to get back to this.

     

    grantjenkins_1-1677587860289.png

     

    Running the flow with four objects would give us something like below:

    [
     {
     "id": 1,
     "displayName": "Bob",
     "department": "HR"
     },
     {
     "id": 2,
     "displayName": "Jane",
     "department": "IT"
     },
     {
     "id": 3,
     "displayName": "Sarah",
     "department": "HR"
     },
     {
     "id": 4,
     "displayName": "Andy",
     "department": "Finance"
     }
    ]

     

    And exactly the same idea for your Select with the SharePoint values. Property names (you can type whatever you want) on the Left, and the actual values on the Right.


    ----------------------------------------------------------------------
    If I've answered your question, please mark the post as Solved.
    If you like my response, please consider giving it a Thumbs Up.

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

Forum hierarchy changes are complete!

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
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard