cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tbelvin
Level: Powered On

Retrieving inner arrays for PowerApps

We have a web service that returns data in the following schema:

  "type": "object",
    "properties": {
        "total": {
            "type": "integer"
        },
        "per_page": {
            "type": "integer"
        },
        "current_page": {
            "type": "integer"
        },
        "last_page": {
            "type": "integer"
        },
        "next_page_url": {},
        "prev_page_url": {},
        "from": {
            "type": "integer"
        },
        "to": {
            "type": "integer"
        },
        "data": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "created_at": {
                        "type": "string"
                    },
                    "updated_at": {
                        "type": "string"
                    },
                    "transferred_at": {
                        "type": "string"
                    },
                    "est_departed_at": {
                        "type": "string"
                    },
                    "est_arrival_at": {
                        "type": "string"
                    },
                    "inventory_transfer_items": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "created_at": {
                                    "type": "string"
                                },
                                "updated_at": {
                                    "type": "string"
                                },
                                "description": {
                                    "type": "string"
                                },
                                "qty": {
                                    "type": "string"
                                },
                                "price": {
                                    "type": "string"
                                },
                                "uom": {
                                    "type": "string"
                                },
                                "received_at": {
                                    "type": "string"
                                },
                                "received_qty": {
									"type": "string"
								},
                                "inventory_type": {
                                    "type": "object",
                                    "properties": {
                                        "created_at": {
                                            "type": "string"
                                        },
                                        "updated_at": {
                                            "type": "string"
                                        },
                                        "name": {
                                            "type": "string"
                                        },
                                        "description": {
                                            "type": "string"
                                        },
                                        "net_weight": {
                                            "type": "string"
                                        },
                                        "packed_qty": {
											"type": "string"
										},
                                        "cost": {
                                            "type": "string"
                                        },
                                        "uom": {
                                            "type": "string"
                                        }
                                    }
                                }
                            },
                            "required": [
                                "created_at",
                                "updated_at",
                                "description",
                                "qty",
                                "price",
                                "uom",
                                "received_at",
                                "received_qty",
                                "inventory_name",
                                "strain_name",
                                "inventory_type"
                            ]
                        }
                    }
                },
                "required": [
                    "created_at",
                    "updated_at",
                    "transferred_at",
                    "est_departed_at",
                    "est_arrival_at",
                    "inventory_transfer_items"
                ]
            }
        }
    }
}

Note there are two nested arrays in the return body - "inventory_transfer_items" and "inventory_type".

 

How do I access the inner arrays within PowerApps? The top level array "data" is no problem - but the next inner array "inventory_transfer_items" shows up as type object. I can't access the elements of "inventory_transfer_items" either. 

 

I want to store the results in a PowerApps collection. Thanks for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Retrieving inner arrays for PowerApps

Hi @tbelvin ,

 

The Schema you provided shows that the type of inventory_transfer_items seems to be array, and the inventory_type seems to be object.

You could try to parse the return body directly using Parse JSON action.

 

I did a test on my side, configured the Schema you provided in Parse JSON, and then traversed the elements in data in Apply to each.

Traverse the elements in inventory_transfer_items in Apply to each 2.

 

There are a lot of properties with the same name when using Dynamic content contained in Parse JSON. You could see which Apply to each is included.

For example, there are three Created_at, if it is items(‘Apply_to_each’)[‘created_at’], it means that it is an property in the element contained in data.

If it is items(‘Apply_to_each_2’)[‘created_at’], it is an property in the element contained in inventory_transfer_items.

If it is items(‘Apply_to_each_2’)[‘ inventory_type’][‘created_at’], it is an property contained in inventory_type.

 

Image reference:

6.PNG

Hope it helps.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Community Support Team
Community Support Team

Re: Retrieving inner arrays for PowerApps

Hi @tbelvin ,

 

The Schema you provided shows that the type of inventory_transfer_items seems to be array, and the inventory_type seems to be object.

You could try to parse the return body directly using Parse JSON action.

 

I did a test on my side, configured the Schema you provided in Parse JSON, and then traversed the elements in data in Apply to each.

Traverse the elements in inventory_transfer_items in Apply to each 2.

 

There are a lot of properties with the same name when using Dynamic content contained in Parse JSON. You could see which Apply to each is included.

For example, there are three Created_at, if it is items(‘Apply_to_each’)[‘created_at’], it means that it is an property in the element contained in data.

If it is items(‘Apply_to_each_2’)[‘created_at’], it is an property in the element contained in inventory_transfer_items.

If it is items(‘Apply_to_each_2’)[‘ inventory_type’][‘created_at’], it is an property contained in inventory_type.

 

Image reference:

6.PNG

Hope it helps.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (4,466)