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

Gallery source from Table() based on variable text

Hi 

 

I'm trying to set the datasource for a gallery based on the function Table()

 

This is working as the datasource for the gallery:

 

Table( { text: "Google"; url: "https://www.google.dk" } )

 

BUT

 

If I instead use this approuch an created the gallery-datasource based on a variable it is not working.

 

sourceText.Text = "{ text: "Google"; url: "https://www.google.dk" }";

Table(sourceText.Text)

 

Why is that not possible, what do I do wrong? Do I have to convert somehow? Please help.

 

Best regards, Jan

5 REPLIES 5
PowerApps Staff ShantanuP
PowerApps Staff

Re: Gallery source from Table() based on variable text

Function Table expects a record input type. 

 

sourceText.Text = "{ text: "Google"; url: "https://www.google.dk" }";

Table(sourceText.Text)

 

Type of sourceText.Text is string. So it's invalid input.

What you can also do is use a set function to create a app variable of this type and pass that as input to Table function.

 

For example,

Set(A, { text: "Google"; url: "https://www.google.dk" })

Table(A)

 

Or you can do something like this.

Table({text: sourceText.Text; url:anotherSourceText.Text})

JanLektonen
Level: Powered On

Re: Gallery source from Table() based on variable text

Hi @ShantanuP

 

Yes that is working for a single record as you suggest.

 

But actually I want several records and Table() will only accept an variable not a collection?

 

So what I try to do now is to make a collection like this to pass on as datasource to the Gallery, but that is not working with the Table().

ClearCollect(JSONCollect; {text:"Google 1"; url:"https://www.google.dk"}; {text:"Google 2"; url:"https://www.google.dk"} )

And if I then just use the JSONCollect as the datasource directly on the Gallery it is working. But the problem is that I have the test(records) in a label.text so what I would like to do is the following - but that is not working or I do something wrong?:

 

sourceText.text = " {text:"Google 1"; url:"https://www.google.dk"}; {text:"Google 2"; url:"https://www.google.dk"}"

Table(sourceText.Text)

 

Any suggestions how I pass on this Sourcetext with multiple records the right way to a collection and then into a gallery?

 {text:"Google 1"; url:"https://www.google.dk"}; {text:"Google 2"; url:"https://www.google.dk"}

PowerApps Staff ShantanuP
PowerApps Staff

Re: Gallery source from Table() based on variable text

You should be able to bind Table like below to Gallery.

 

Table({text:"Google 1"; url:"https://www.google.dk"}; {text:"Google 2"; url:"https://www.google.dk"})

 

Alternatively here is what you can do.

 

Add a input text let's say TextInput1 and set TextInput1.Default = ""

Add another input text let's say UrlInput and set UrlInput.Default = ""

Add a button and write below expression OnSelect

 

OnSelect = Collect(JSONCollect; {text: TextInput1.Text; url: UrlInput.Text}); Reset(TextInput1); Reset(UrlInput)

 

Then you can add as many entries as you want to populate JSONCollect collection by entering new values to TextInput1 and UrlInput.

JanLektonen
Level: Powered On

Re: Gallery source from Table() based on variable text

Hi @ShantanuP

 

Great solution. But it involves that I click for each record. I have to convert a JSON textstring directly into a datacollection or like to be uses as a datasource in a gallery.

 

Do you know if it is possible to have a JSON datastring/source and create a collection based on these fields to be used in Powerapps?

PowerApps Staff ShantanuP
PowerApps Staff

Re: Gallery source from Table() based on variable text

Unfortunately this is not supported in powerapps. What you can do is write a custom API which returns a tabular data. You can then call this API from Powerapps just like any other function.

https://powerapps.microsoft.com/en-us/blog/register-and-use-custom-apis-in-powerapps/

https://powerapps.microsoft.com/en-us/blog/brand-new-custom-api-experience-in-powerapps/

https://docs.microsoft.com/en-us/connectors/custom-connectors/create-web-api-connector

Helpful resources

Announcements
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 268 members 6,432 guests
Please welcome our newest community members: