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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (61,072)