web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Gallery source from Ta...
Power Apps
Unanswered

Gallery source from Table() based on variable text

(0) ShareShare
ReportReport
Posted on by

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

Categories:
I have the same question (0)
  • ShantanuP Profile Picture
    on at

    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})

  • Community Power Platform Member Profile Picture
    on at

    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"}

  • ShantanuP Profile Picture
    on at

    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.

  • Community Power Platform Member Profile Picture
    on at

    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?

  • ShantanuP Profile Picture
    on at
    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard