cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
martinav
Super User
Super User

I need to call for a record in a gallery item, to reduce sql calls.

I have a gallery that I wish to call a record into it, so that I can reference in multiple labels.  This would eliminate repeated calls to a SQL table.  Is there a way to do this?

 

In context of a Gallery:

This works, in a Label.Text

 

 

First(Lookup(SQL_table, Index=Thisitem.Idx)).Name

 

 

 Result is: "Bob"

 

What I want to work, in a Label.Text or whatever:

 

 

First(Lookup(SQL_table, Index=Thisitem.Idx))

 

 

Then, in Label2.Text.Name

Result: "Bob"

 

Label3.Text.State

Result: "Texas"

 

Is there an object I can do this, instead of making multiple calls for the same record?

3 REPLIES 3
timl
Super User
Super User

@martinav 

In your gallary, are the lookup items that you want to display grouped relatively together?

If so, perhaps you could do this with a nested child gallery. You'd set the Items property to

Table(First(Lookup(SQL_table, Index=Thisitem.Idx)))

..and in the child gallery template, you can just reference ThisItem.Name, ThisItem.State etc.

martinav
Super User
Super User

@timl ,

 

I had tried this.  Fooled a bit more with it too.  It shows the columns, but the table doesnt have any data in it.  Exactly as you said, with the lookup in item.  It obviously is written correct because the columns are there, but why no data?

 

The table works outside of the gallery, but with the driving search criteria is thisitem.xxxxx, then its not returning anyting.  Just field info.

timl
Super User
Super User

@martinav 

I suspect the most likely culprit is "explicit column selection".

If you wrap ShowColumns around the LookUp and include the columns you want to show, does that make a difference?

Table(
 First(
      ShowColumns(Lookup(SQL_table, Index=Thisitem.Idx),
        "Name",
        "State",
        "etc.."
      )
  )
)

 

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,945)