cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
StevePenner
Helper I
Helper I

Referencing Values in Collections

In the use of collections, I am finding the ability to reference values in them very unintuitive.

Even with the intellisense formula bar showing "Table" or "Record" or other primitive to complex data type, I came up with what I wanted only by ultimately stumbling upon it after several hours (!).

In one screen, a button was used with following OnSelect formula:

 

 

 

UpdateContext({MeetingDate: MeetingDatePicker.SelectedDate});
ClearCollect(AgendaCreate, {MeetingDate: MeetingDate, AgendaItems: 'CAB Agenda Admin'.'Level 1 Header'});
Navigate(EditAgendaItems,ScreenTransition.Fade)

 

 

 

In an image below, the collection shows a property (column?) "MeetingDate" with datetime value and a property "AgendaItems" shows a table, which is expanded to show a single column of rows of text.

In the next screen, these two properties (columns?) are utilized, the date converted to text and concatenated to
text in a text label

 

 

 

"Meeting Date: " & Text(First(AgendaCreate.MeetingDate).MeetingDate, DateTimeFormat.ShortDate)

 

 

 

and the single column table of text used to form the options in a scrollable list box.

 

 

 

First(AgendaCreate.AgendaItems).AgendaItems

 

 

 

The image of the screen and selected controls with their formula are indicated.


I have a feeling I am doing this wrong, because the patterns

 

 

 

First(AgendaCreate.MeetingDate).MeetingDate
First(AgendaCreate.AgendaItems).AgendaItems

 

 

 

are confusing. This states that AgendaCreate.MeetingDate is of type 'Table' when it seems not to be, and that it nonetheless returns a value of type 'Record' where we get the field 'MeetingDate'.

AgendaItems is clearly a property of collection AgendaCreate, and is intuitively a table, but First() returns a record that is a table. Seemingly a table within a table, which is not the case.

 

Why doesn't AgendaCreate.MeetingDate simply return the datetime value and AgendaCreate.AgendaItems.(columnName?) return the rows of text to be used as Items?  That seems intuitive to me.

 

-------------------------------------------------------------------------------------------------------

 

Fig1.pngFig2.png

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @StevePenner :

It looks like you have already got the value you want.

Do you just want to know why you should use 

 

First(AgendaCreate.MeetingDate).MeetingDate

 

instead of

 

AgendaCreate.MeetingDate

 

?

The point is  the value of AgendaCreate.MeetingDate is a list of datetime value.If you need to get a specific MeetingDates, you need to specify which record it comes from.So you can use 

 

First(AgendaCreate).MeetingDate

 

or

 

First(AgendaCreate.MeetingDate).MeetingDate

 

to get the MeetingDate in the first record in the table AgendaCreate.

Then,let‘s go back to the agendaitems field.

AgendaCreate.AgendaItems is a list of tables.So the value of 

 

First(AgendaCreate.AgendaItems).AgendaItems

 

or

 

First(AgendaCreate).AgendaItems

 

is a table in AgendaItems field in the first record of the table AgendaCreate .So it can be used as items property of the list box control.If you want to display it in a label control,you can try this :

Add a label control and set it's Text property to:

 

Concat(First(AgendaCreate).AgendaItems,Title,Char(13))

 

Best Regards,

Bof

 

 

 

View solution in original post

1 REPLY 1
v-bofeng-msft
Community Support
Community Support

Hi @StevePenner :

It looks like you have already got the value you want.

Do you just want to know why you should use 

 

First(AgendaCreate.MeetingDate).MeetingDate

 

instead of

 

AgendaCreate.MeetingDate

 

?

The point is  the value of AgendaCreate.MeetingDate is a list of datetime value.If you need to get a specific MeetingDates, you need to specify which record it comes from.So you can use 

 

First(AgendaCreate).MeetingDate

 

or

 

First(AgendaCreate.MeetingDate).MeetingDate

 

to get the MeetingDate in the first record in the table AgendaCreate.

Then,let‘s go back to the agendaitems field.

AgendaCreate.AgendaItems is a list of tables.So the value of 

 

First(AgendaCreate.AgendaItems).AgendaItems

 

or

 

First(AgendaCreate).AgendaItems

 

is a table in AgendaItems field in the first record of the table AgendaCreate .So it can be used as items property of the list box control.If you want to display it in a label control,you can try this :

Add a label control and set it's Text property to:

 

Concat(First(AgendaCreate).AgendaItems,Title,Char(13))

 

Best Regards,

Bof

 

 

 

Helpful resources

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

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (5,516)