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

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
Super User
Super User

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

@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.

View solution in original post

5 REPLIES 5
JohnP
Level 8

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

Set the label text to ThisItem.Artist

pwapp
Level: Powered On

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

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 🙂

Super User
Super User

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

@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.

View solution in original post

pwapp
Level: Powered On

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

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!

Super User
Super User

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

@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.

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (6,322)