cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pwapp
Frequent Visitor

Problem viewing Items in a Gallery from a Collection with a Json Data Source

Hi Everyone,

 

I am returning a multi-row json object (see screenshot/json below) from a flow into PowerApps via 

ClearCollect(mycollection,'exampleflow'.Run())

to load it into a collection. The collection populates as expected and I can see its contents when I view the collection in PowerApps collections explorer (see screenshot).

 

example.png

 

However when I set the gallery datasource as 'mycollection' and try to populate labels in the gallery via: 

ThisItem.Catalog.CD.Artist 

I get the following error message: "Expected Text Value". However, if I use:

First(ThisItem.Catalog.CD).Artist

then the gallery returns the first row from within the collection but none of the other rows for Bonnie, Dolly etc  (which I want to see!)

example3.PNG

 

It feels like I'm missing something very simple!! Does anyone have any ideas about how best to display a nested json collection data in a gallery????

 

Thanks!

 

---------------------------------------------

 

Here is the example json I am using:

 

{
  "CATALOG": {
    "CD": [
      {
        "TITLE": "Empire Burlesque",
        "ARTIST": "Bob Dylan",
        "COUNTRY": "USA",
        "COMPANY": "Columbia",
        "PRICE": "10.90",
        "YEAR": "1985",
        "ORACLE": "\n  select * from scott.dept;\n  "
      },
      {
        "TITLE": "Hide your heart",
        "ARTIST": "Bonnie Tyler",
        "COUNTRY": "UK",
        "COMPANY": "CBS Records",
        "PRICE": "9.90",
        "YEAR": "1988"
      },
      {
        "TITLE": "Greatest Hits",
        "ARTIST": "Dolly Parton",
        "COUNTRY": "USA",
        "COMPANY": "RCA",
        "PRICE": "9.90",
        "YEAR": "1982",
        "ORACLE": "\n  begin\n  htp.p('This is the test data');\n  end;\n  "
      },
      {
        "TITLE": "Still got the blues",
        "ARTIST": "Gary Moore",
        "COUNTRY": "UK",
        "COMPANY": "Virgin records",
        "PRICE": "10.20",
        "YEAR": "1990"
      }
    ]
  }
}

I have confirmed that the json is valid in a json validator

1 ACCEPTED SOLUTION

Accepted Solutions

@pwapp 

I believe the issue here is that you are expecting to itterate over the Artist values in your gallery.  However, I'm guessing that you have the items property of the gallery set to your collection.

This will itterate over all the records in the myCollection collection...to which there is only 1 record - CATALOG.

 

If you change your Items property on the Gallery to First(myCollection).CATALOG.CD

you will then be able to use things like ThisItem.Artist

Based on your sample data, you have a single record with a CATALOG column that contains a table of records with a CD column, that contains a table/array of the information I believe you really want.

 

See if that is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

6 REPLIES 6
JohnP
Kudo Kingpin
Kudo Kingpin

Set the label text to ThisItem.Artist

pwapp
Frequent Visitor

Hi,

Thanks @JohnP , just tried that and i don't think it works unfortunately. Do you know why?

Example:

ThisItem.Artist

Eror mesage is 'Name isn't valid. This identifier isn't recognized':

example4.png

 

I'm a bit stumped! I think this should be simple? Am i missing something obvious??

 

Thanks 🙂

@pwapp 

I believe the issue here is that you are expecting to itterate over the Artist values in your gallery.  However, I'm guessing that you have the items property of the gallery set to your collection.

This will itterate over all the records in the myCollection collection...to which there is only 1 record - CATALOG.

 

If you change your Items property on the Gallery to First(myCollection).CATALOG.CD

you will then be able to use things like ThisItem.Artist

Based on your sample data, you have a single record with a CATALOG column that contains a table of records with a CD column, that contains a table/array of the information I believe you really want.

 

See if that is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

pwapp
Frequent Visitor

Hi @RandyHayes

 

Ah, perfect! That works great thanks! Thanks for taking the time to explain how to pull it together - I didn't know you could amend the the items property like that.

 

Thanks!

@pwapp 

Yes, the Items property of a gallery just needs a table.  In this case, we are providing it a table that it wants, and it is at a level in the collection that makes sense for the information you want to display.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
wsalling
Helper III
Helper III

how are you getting the JSon back from powerapps so you can use it in a collection?  stuck at moment.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,561)