cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cmanning
Helper II
Helper II

Convert Object to an Array Within an Apply to Each

I have a flow that retrieves all items from a SP list which contains several columns of multi-select choice columns and converts to the Dataverse equivalent as it inserts new rows.  As it retrieves all the items from the multi-select choice column, I am performing certain actions.  One of the things I need to do is convert the "Resource Types" multi-select choice object to an array so I can perform additional actions.  The flow run is shown below and fails later because I am trying to perform an action on an array but it is an object that must converted to an array first. 
DI App Flow - Convert Object to Array for Multi-Select Choice cols ERR.png
Shown above is the Compose action showing that "Resource Types" is an object and I need to convert it to an array.  Below is the full code for the object.  

 

[
    {
        "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        "Id": 0,
        "Value": "Bid Manager"
    },
    {
        "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        "Id": 1,
        "Value": "Solution Consultant"
    },
    {
        "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        "Id": 7,
        "Value": "Legal/Contract"
    },
    {
        "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        "Id": 6,
        "Value": "Pricer"
    }
]

 

Since I need to convert the object to an array within an Apply to each, what is the best method?  The new array in this instance should be as shown below.

[
  "Bid Manager",
  "Solution Consultant",
  "Legal/Contract",
  "Pricer"
]
1 ACCEPTED SOLUTION

Accepted Solutions
ekarim2020
Super User
Super User

Your data is already an array; it's an array of JSON objects.

If I have understood correctly, you want to extract the Value property from the JSON array. The result will be an array of strings:

[
  "Bid Manager",
  "Solution Consultant",
  "Legal/Contract",
  "Pricer"
]

 

To do this, please try:

Snag_53a18ea.png

 

This is the runtime output:

Snag_53ac651.png

Hope this helps.


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

 

View solution in original post

2 REPLIES 2
ekarim2020
Super User
Super User

Your data is already an array; it's an array of JSON objects.

If I have understood correctly, you want to extract the Value property from the JSON array. The result will be an array of strings:

[
  "Bid Manager",
  "Solution Consultant",
  "Legal/Contract",
  "Pricer"
]

 

To do this, please try:

Snag_53a18ea.png

 

This is the runtime output:

Snag_53ac651.png

Hope this helps.


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

 

@ekarim2020 - Ellis thanks again for another solution!! It is much appreciated. 

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (1,095)