cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ericonline
Community Champion
Community Champion

Unable to Clear Nested Collection

Weirdest thing. 

  • OnVisible of Screen:
    • Intantiate a nested Collection with a blank record then Clear the collection
    • ClearCollect(colStatus,
          Table(
              {
                  Level2:
                  Table(
                      {
                          Level3_A: {
                              ID: " ",
                          },
                          Level3_B:{
                              Indicator: " "
                          }
                      }
                  )
              }
          )
      );
      
      Clear(colAirStatuses)
  • Label on Screen:
    • Text property: CountRows(colStatus)
    • Results: 1
  • The colStatus record:
    • The first record in the Gallery.
    • Each record in the Gallery has a toggle that Collects data. 
    • But the toggle is NOT toggled by me OnVisible...

When a screen loads, does the first Toggle in a Gallery "flip" to whatever the default is set to? Maybe this is whats happening? 

To mitigate, I added a .001 second timer to the screen OnTimerEnd Clear(colStatus) and it works without user noticing... but still ..? Weird!

 

1 REPLY 1
v-xida-msft
Community Support
Community Support

Hi @ericonline ,

Could you please share a bit more about your scenario?

Do you want to clear Nested Collection from a Collection?

Further, do you want the Toggle control to "flip" to whatever the default is set to when you load your screen?

 

I found that you have posted similar issue within this forum, please check my response within the following thread:

https://powerusers.microsoft.com/t5/General-Discussion/Toggle-Mindboggle/m-p/258427#M75604

If you want to clear nested Collection from a Collection, please take a try with the solution I provided within above thread.

 

In addition, if you want the Toggle control to "flip" to whatever the default is set to when you load your screen, I think the OnVisible property could achieve your needs.

I assume that you add a Status column ("Y" or "N") in your colStatus collection to store the Toggle value as below (set the OnVisible proeprty of the screen to following😞

ClearCollect(
              colStatus,
              Table({
                  Level2: Table({
                      Level3_A: {
                          ID: " "
                      },
                      Level3_B: {
                          Indicator: " ",
                          Status: "Y"    /* <-- Store the Toggle value */
                      }
                  })
              })
)

Add Gallery control, set the Items property to following:

colStatus

Within the Gallery, set the Default property of the Toggle control to following:

If(
First(ThisItem.Level2.Level3_B).Level3_B.Status = "Y",
true,
false
)

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (15,152)