cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JR-BejeweledOne
Super User
Super User

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

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


)

 

 

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
1 ACCEPTED SOLUTION

Accepted Solutions
CNT
Super User
Super User

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

View solution in original post

4 REPLIES 4
CNT
Super User
Super User

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

View solution in original post

JR-BejeweledOne
Super User
Super User

That is awesome!  I was unaware of that function. 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

@JR-BejeweledOne Glad to help and share!

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.



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,876)