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 / Can I trigger code to ...
Power Apps
Unanswered

Can I trigger code to be executed when a value of a control changes (but without it being selected).

(0) ShareShare
ReportReport
Posted on by 18

HI,

I have a calendar control on a screen that is hidden by default.  When I press a calendar icon, It display on the screen and I can select a date.  When I click on a date, the control is again hidden and the date passed back to the screen.

 

I need to also execute code on that screen when the date changes.

 

I tried a hack by attaching the context variable to a checkbox's default state - This does indeed change the checkbox to checked when the calendar is shown and unchecked when it is hidden - unfortunately I cannot get the OnUnchecked event to trigger.

 

As per the attached image I tried to debut - my label never changes to "On check triggered" or "On Unchecked triggered".  The CustomOutputVisibility does change the checked state - but no code is triggered.

dlortie_0-1601968586818.png

 

Are other hack to get this to work ?

 

Thanks,

Daniel

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @dlortie 

    You cannot assign values to properties in PowerApps like you are doing in the Formula on the OnCheck and OnUncheck action of your CheckBox.

    You must derive values from controls or variables (preferably controls - don't overuse variables).

    Below as taken from the Docs:

    In general, avoid using variables. But sometimes only a variable can enable the experience you want. Variables are implicitly created and typed when they appear in functions that set their values.

    So in your case, you would focus on the Label, not the control.

    Set the Label Text property formula to the following:

    If(Checkbox1.Value, 
     "CheckBox is Checked",
     "Checkbox is Not Checked"
    )

     

    And if you find you don't really need a Checkbox for your screen, you can shortcut directly to your CustomOutputVisibility property with this formula:

    If(cmp_Schedule_Calendar.CustomOutputVisibility, 
     "CustomOutputVisibility is true",
     "CustomOutputVisibility is false"
    )

     

    I hope this is helpful for you.

  • dlortie Profile Picture
    18 on at

    Hi,

     

    I was trying to debug - even if I put the code as you have shown, the text is not displayed.

    The checkbox control is only a hack/debug.

     

    The requirement/goal is to have some code that is stored in a hidden button to run when another control becomes hidden (visible = false).  I can do this by calling Select(<hidden_button_name>)...but I have not figured out a way to call this when a component hides itself (basically a calendar component the closes itself when a date is selected).

     

    Thanks,
    Daniel

  • dlortie Profile Picture
    18 on at

    In case it help anyone new to PowerApps...I figured out how to do this by using a timer control and using the context variable that is used to show or hide the component.

     

    Similar to this post: https://officepoweruser.com/how-to-create-a-popup-confirmation-in-powerapps/

     

    Regards,
    Daniel

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @dlortie 

    You're over complicating your app!  

     

    If you want to have some Formula run when something changes - you can utilize a Toggle control to do it.  Set the default of the toggle to a variable you want.  Put the Formula you want in the OnCheck action and at the end of the formula, return the variable you used to a false value.  Then when you want to execute the formula, just set the variable to true.  It's quite simple and no timers are needed.

     

    I hope this is helpful for you.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#2
11manish Profile Picture

11manish 205 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard