Skip to main content
Community site session details

Community site session details

Session Id : xJWb81HbPyaa1V2Sg0q/Vi
Power Apps - Building Power Apps
Answered

Order of running the "OnSelect" and "OnChange" triggers

Like (0) ShareShare
ReportReport
Posted on 5 Dec 2022 12:54:31 by 84

Hi,

 

I'm trying to create a power app in which i have a questionnaire, with possibility to add a picture if a specific value is selected.

I'm Using a Form, and due to Lay-out limitations i can not  have the capture picture together in the "Edit Form" Control.

 

So in case a picture needs to be taken, the current form will be submitted. and in the next screen the picture will be added. After this the user will be returned to the first screen.

 

in order to reduce the amount of clicks, i use a slicer (in below example called Req02) to enter the values. with a minimum value of 1, and a maximum value of 5. I also would like to change the Fill color of the DataCard in case the question was answered in a previous screen. (this to make it clear to the user which questions he already has answered.)

 JeanPhilippevb_0-1670242251722.png

For this i use in the "Fill" section of the datacard below function

If(ReqVal02=Blank(),

     RGBA(0,0,0,0),

     RGBA(226, 250, 230, 0.7))

Via the "OnChange" i would fill in the Variable

Set(ReqVal02,Req02.Value)

 

But because the use of the Slicer: at the moment it will submit the form (to take the picture), it will select automatically the lowest  Value, and thus it will always change the 'blank()' Value of the field even i the user didn't change them. So All questions will be marked as green (Value 1).

 

I tried to fix this by using the "OnChange" property of the slicer: i was hoping to block this off, So it would only register "manual" changes to the slicer:

 

"OnSelect":

UpdateContext({OnSel02: 1})

"OnChange" 

If(OnSel02=1,

     Set(ReqVal02,Req02.Value);UpdateContext({OnSel02: 0}),

     Set(ReqVal02,Blank()))

"Default"

If(ReqVal02=Blank(),1,ReqVal02)

 

But it seems the "On Change" is triggered before the "OnSelect", so with this setup it is not possible to change the value of the slicer at all.

 

I have the feeling i'm over complicating it, though i don't see much alternatives now (using a dropdown would make it possible, though the user experience would not be the same).

Any advice you can give me?

 

  • cha_cha Profile Picture
    4,932 Moderator on 05 Dec 2022 at 14:42:54
    Re: Order of running the "OnSelect" and "OnChange" triggers

    Hi,

     

    Happy that you got it sorted. You should mark your response as the answer as maybe someone might stumble on the same issue in the future.

     

  • Verified answer
    Jean-Philippevb Profile Picture
    84 on 05 Dec 2022 at 14:40:22
    Re: Order of running the "OnSelect" and "OnChange" triggers

    Hi Cha_Cha,

     

    I found the solution: 

    Via the "OnChange" i would fill in the Variable

    Set(ReqVal02,Req02.Value)

    "OnSelect":

    UpdateContext({OnSel02: 1})

    and with the OnVisible parameter of the Screen i put:

    If(OnSel02<>1,Set(ReqVal02,Blank()));

     

    so i'm blanking out the Values in case the values had not been changed manually. (which allowed me to keep using the slider).

    The radio control could have worked, to the feeling of it is different.

     

    Regarding the delegation warning, i did follow the tips and tricks from Reza (see minute 7:10), so i'm filtering in my data as much as possible on validated fields, but in order to get the value of a specific record i understand i Best use the "first()" instead of the Lookup function, This did fix the delegation warning now.

    JeanPhilippevb_1-1670251125987.png

     

    For the tabs, i'm using it in other apps, and will definitely do it also in the monthly audit form (to be added later).

     

    Kind Regards,

    Jean-Philippe

     

  • cha_cha Profile Picture
    4,932 Moderator on 05 Dec 2022 at 13:29:01
    Re: Order of running the "OnSelect" and "OnChange" triggers

    Hello @Jean-Philippevb 

     

    • UI-wise, use a Radio control instead of a slider. This makes it easy for users to select the option they want navigating from 1 to 5 every time.
    • As for your case, if you want to stay with Slider, use only the OnChange

    I did a short demo for both: https://youtu.be/XuY7PelXtiM

     

    Advice for your app:


      ✔️
    Just in case my response helped you solve your problem, please mark/accept this as a SOLUTION This helps community members if they experience a similar issue in the future.

     

      🔗
    🕸bistek.space  🐦 @cha_bistek  📺 @BisTekSpace 

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading started
Loading complete