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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Toggle switch onchange...
Power Apps
Answered

Toggle switch onchange triggered by selecting different items

(0) ShareShare
ReportReport
Posted on by 34

Hello,

 

I have patch function working with a toggle switch onchange property.  I want to patch some info when it's switched on/off.

 

If(tglTowerOnHoldA.Value = true,Patch('P2 Batch Sheets',ThisItem,{'Tower On Hold':'Tower On Hold (P2 Batch Sheets)'.Yes});Set(gblOnHoldTime,ThisItem.'Tower On Hold Time');Set(gblOnHoldDate,Now()),Patch('P2 Batch Sheets',ThisItem,{'Tower On Hold':'Tower On Hold (P2 Batch Sheets)'.No,'Tower On Hold Time':locOnHoldTime,'Tower On Hold Date':Blank()}))

 

 

The default of toggle is set to be the item's on hold column value.

 

 

If(ThisItem.'Tower On Hold' = 'Tower On Hold (P2 Batch Sheets)'.Yes,true,false)

 

 

However, every time I select a different, let's say from one with on hold to a new one with not on hold, the onchange property got triggered automatically. Does anyone know a way to sort this out?

 

Thanks,  

Categories:
I have the same question (0)
  • v-qiaqi@microsoft.com Profile Picture
    on at

    Hi @BigGGG777,

    Do you mean that the OnChange property triggers when you update an item with Toggle value from yes to no?

    I want to explain to you that it is how the OnChange property works that a value changes from yes to no.

  • BigGGG777 Profile Picture
    34 on at

    Hi @v-qiaqi-msft ,

     

    Thanks for replying. I didn't mean that. My app currently has 2 layers, the top layer is a gallery which you can select item. The second layer is the item form itself. By that, I mean, when I select one item with the value equals to 'Yes' and then go back to top gallery and select another item whose value is 'No', then the OnChange  of toggle automatically triggered. I want a way to avoid this.

  • Verified answer
    Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @BigGGG777 

     

    not sure if it will resolve the issue but you can try:

    If(
     tglTowerOnHoldA.Value = true && ThisItem.'Tower On Hold' = 'Tower On Hold (P2 Batch Sheets)'.No,
     Patch('P2 Batch Sheets', ThisItem, 
     {
     'Tower On Hold': 'Tower On Hold (P2 Batch Sheets)'.Yes
     }
     );
     Set(gblOnHoldTime, ThisItem.'Tower On Hold Time');
     Set(gblOnHoldDate, Now())
     ,
     
     tglTowerOnHoldA.Value = false && ThisItem.'Tower On Hold' = 'Tower On Hold (P2 Batch Sheets)'.Yes,
     Patch('P2 Batch Sheets', ThisItem, 
     {
     'Tower On Hold': 'Tower On Hold (P2 Batch Sheets)'.No,
     'Tower On Hold Time': locOnHoldTime,
     'Tower On Hold Date': Blank()
     }
     )
    )

     

    If it does not work, i would place your original code to be triggered  by a separate button.OnSelect (and tglTowerOnHoldA.OnChange=false).

     

    If both do not work, i have no other ideas without having all the app's code.

     

  • BigGGG777 Profile Picture
    34 on at

    Thanks, get it working with 1 extra button with 1 more condition.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard