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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Best way to initially ...
Power Apps
Answered

Best way to initially populate items for the Default Gallery Selected.

(0) ShareShare
ReportReport
Posted on by 5,836 Moderator

When the app opens it shows a schedule for the current week in a series of 3 galleries.   While it appears that the first item in the first 2 galleries is selected, it is not populating all of the information in the 3rd gallery.    Some of the information is obtained when an item in gallery 2 is selected.   I need to duplicate the OnSelect action from the 2nd gallery to happen in the onVisible of the screen so the information in the 3rd gallery is populated correctly when the app is initially opened.

 

What I tried to do is take that same formula and put it in the onVisible for the screen, and modified the items from 'ThisItem.PrimaryContact' to 'GalleryOnCallTeam.Selected.PrimaryContact.   No errors or red squigglies, but it's not getting the information either.

 

All 3 galleries are using information from colSptSchedule.   The 3rd Gallery is also using collections: Primary, Backup, Escalation and Primary2.

 

colSptSchedule:

 

 

ForAll(
 OnCallSchedule As SC,
 
 Collect(
 colSptSchedule,
 { 
 PrimaryContact: If("," in SC.PrimaryContact, First(TrimEnds(Split(SC.PrimaryContact,","))).Result, SC.PrimaryContact),
 PrimaryContact2: If("," in SC.PrimaryContact, Last(TrimEnds(Split(SC.PrimaryContact,","))).Result, ""),
 BackUpContact: SC.BackUpContact,
 Date: SC.Title,
 EscalationManager: SC.EscalationManager,
 ScheduleNotes: SC.ScheduleNotes,
 TeamNotes: LookUp(TeamsSupportInfo, Title = SC.Team).Schedule_x0020_Notes,
 Team: SC.Team
 
 }
 )
),

 

 

Gallery #1 - GallerySchedule - Items:

 

 

GroupBy(
 Filter(
 colSptSchedule, Date = Text(Monday) Or Date = Text(Friday)),
 "Date", "Details"
 )

 

 

Gallery #2 - GalleryOnCallTeam Items:

 

Filter(colSptSchedule, Date = GallerySchedule.Selected.Date)

 

 

Gallery #3 - GalleryOnCallTeamInfo Items:

 

 

GalleryOnCallTeam.Selected

 

 

Formula that populates Primary, Backup, Escalation and Primary2.   I copied this and added it to the OnVisible for the screen, replacing the 'ThisItem.XXX References with 'GalleryOnCallTeam.Selected.XXX'.    It works correct when an item is manually selected in the 2nd gallery, but does not collect any information for Primary, Backup, Escalation or Primary2 in the OnVisible of the screen.

 

 

Concurrent(

With(
 {wFilterPrimary:
 LookUp(ITContacts, Email = ThisItem.PrimaryContact)
},

 ClearCollect(Primary,
 {
 Number: wFilterPrimary.WorkPhone,
 Type: "Business Phone: ",
 Order:
 If(
 wFilterPrimary.PrimaryAfterHoursPhone.Value = "Business Phone", 1,
 wFilterPrimary.PrimaryAfterHoursPhone.Value = "Mobile Phone", 2,
 3
 )
 },

 {
 Number: wFilterPrimary.CellPhone,
 Type: "Mobile Phone: ",
 Order:
 If(
 wFilterPrimary.PrimaryAfterHoursPhone.Value = "Mobile Phone", 1,
 2
 )
 },
 
 {
 Number: wFilterPrimary.HomePhone,
 Type: "Home Phone: ",
 Order:
 If(
 wFilterPrimary.PrimaryAfterHoursPhone.Value = "Home Phone", 1,
 wFilterPrimary.PrimaryAfterHoursPhone.Value = "Other Phone", 4,
 3
 )
 },

 {
 Number: wFilterPrimary.Other_x0020_Phone,
 Type: "Other Phone: ",
 Order:
 If(
 wFilterPrimary.PrimaryAfterHoursPhone.Value = "Other Phone", 1,
 4
 )
 }
 )
),

With(
 {wFilterBackup:
 LookUp(ITContacts, Email = ThisItem.BackUpContact)

},


 ClearCollect(Backup,
 {
 Number: wFilterBackup.WorkPhone,
 Type: "Business Phone: ",
 Order:
 If(
 wFilterBackup.PrimaryAfterHoursPhone.Value = "Business Phone", 1,
 wFilterBackup.PrimaryAfterHoursPhone.Value = "Mobile Phone", 2,
 3)
 },

 {
 Number: wFilterBackup.CellPhone,
 Type: "Mobile Phone: ",
 Order:
 If(
 wFilterBackup.PrimaryAfterHoursPhone.Value = "Mobile Phone", 1,
 2
 )
 },
 
 {
 Number: wFilterBackup.HomePhone,
 Type: "Home Phone: ",
 Order:
 If(
 wFilterBackup.PrimaryAfterHoursPhone.Value = "Home Phone", 1,
 wFilterBackup.PrimaryAfterHoursPhone.Value = "Other Phone", 4,
 3
 )
 },

 {
 Number: wFilterBackup.Other_x0020_Phone,
 Type: "Other Phone: ",
 Order:
 If(
 wFilterBackup.PrimaryAfterHoursPhone.Value = "Other Phone", 1,
 4
 )
 }
 )
),

With(
 {wFilterEscalation:
 LookUp(ITContacts, Email = ThisItem.EscalationManager)

},
ClearCollect(Escalation,
 {
 Number: wFilterEscalation.WorkPhone,
 Type: "Business Phone: ",
 Order:
 If(
 wFilterEscalation.PrimaryAfterHoursPhone.Value = "Business Phone", 1,
 wFilterEscalation.PrimaryAfterHoursPhone.Value = "Mobile Phone", 2,
 3)
 },

 {
 Number: wFilterEscalation.CellPhone,
 Type: "Mobile Phone: ",
 Order:
 If(
 wFilterEscalation.PrimaryAfterHoursPhone.Value = "Mobile Phone", 1,
 2
 )
 },
 
 {
 Number: wFilterEscalation.HomePhone,
 Type: "Home Phone: ",
 Order:
 If(
 wFilterEscalation.PrimaryAfterHoursPhone.Value = "Home Phone", 1,
 wFilterEscalation.PrimaryAfterHoursPhone.Value = "Other Phone", 4,
 3
 )
 },

 {
 Number: wFilterEscalation.Other_x0020_Phone,
 Type: "Other Phone: ",
 Order:
 If(
 wFilterEscalation.PrimaryAfterHoursPhone.Value = "Other Phone", 1,
 4
 )
 }
 )
),

If(
 !IsBlank(ThisItem.PrimaryContact2),

With(
 {wFilterPrimary2:
 LookUp(ITContacts, Email = ThisItem.PrimaryContact2)
},

 ClearCollect(Primary2,
 {
 Number: wFilterPrimary2.WorkPhone,
 Type: "Business Phone: ",
 Order:
 If(
 wFilterPrimary2.PrimaryAfterHoursPhone.Value = "Business Phone", 1,
 wFilterPrimary2.PrimaryAfterHoursPhone.Value = "Mobile Phone", 2,
 3
 )
 },

 {
 Number: wFilterPrimary2.CellPhone,
 Type: "Mobile Phone: ",
 Order:
 If(
 wFilterPrimary2.PrimaryAfterHoursPhone.Value = "Mobile Phone", 1,
 2
 )
 },
 
 {
 Number: wFilterPrimary2.HomePhone,
 Type: "Home Phone: ",
 Order:
 If(
 wFilterPrimary2.PrimaryAfterHoursPhone.Value = "Home Phone", 1,
 wFilterPrimary2.PrimaryAfterHoursPhone.Value = "Other Phone", 4,
 3
 )
 },

 {
 Number: wFilterPrimary2.Other_x0020_Phone,
 Type: "Other Phone: ",
 Order:
 If(
 wFilterPrimary2.PrimaryAfterHoursPhone.Value = "Other Phone", 1,
 4
 )
 }
 )
 )
)


)

 

 

 

 

Categories:
I have the same question (0)
  • Verified answer
    CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @JR-BejeweledOne The Select function simulates a select action on a control, causing the OnSelect formula to be evaluated.

    In the OnVisible, do this,

    Select(gallery, 1)

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    That is awesome!  I was unaware of that function. 

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @JR-BejeweledOne Glad to help and share!

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    Have you ever had any issues with this not running the formula?   I am using this in Power Apps for Teams and seeing some strange behavior.    It worked at first but after saving the app and returning to it the next day it doesn't seem to be working as it should.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 534

#2
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard