cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ngreen
Resolver I
Resolver I

Track if button was pressed.

I'm kinda stumped on what I am trying to build. I have a screen that pops up based on logic of if certain or so many questions were answered "yes." But I also have a button where someone can manually bring up the screen, if they feel it is necessary. I want to track if that screen was brought up and submit it with a yes or no value to a text column in SharePoint. Now, I have it working for the logic, but I'm stumped on how to track it the button was pressed on not. I thought about an OnVisible to do an UpdateContext for a variable, but then it can't reset after each submission. And if I do an OnVisible to set it false, then if someone navigates backwards into the app and then comes back to the OnVisible screen, it would set that value back to "No" even if they clicked the button. Anyone have ideas on what I could try? The issue is I need it to reset back to a "no" on submissions.

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User
Super User

@ngreen 

From what I can tell you have 2 screens:

 

Screen1:  Always appears.  Holds the button to navigate to Screen2

Screen2:  Appears only when conditions are met on Screen1.

 

Write the following code in the OnStart property of your app.

 

Set(ShowScreen2,"No")

 

Then in the OnSelect property of the button on Screen1 write the following code

 

Set(ShowScreen2,"Yes");Navigate(Screen2,None)

 

The OnStart property will ensure your variable always intializes as "No".  We use a SET variable allows you to store a value globally.  That means the value remains stored even as the user progresses to other screens.  In this case it is an ideal alternative to UPDATECONTEXT for the reasons you have already mentioned.

 

Then later on you can submit the ShowScreen2 variable to the proper column whne the user submits the form.

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

 

View solution in original post

5 REPLIES 5
R3dKap
Super User
Super User

Hi @ngreen,

I suggest that in the OnSelect event of your button you set a variable (let's call it gloButtonPuhsed) to true.

Then, right after submitting your data to SharePoint, reset your variable gloButtonPushed to false.

Would that work for you ? Or maybe I didn't catch up what you're trying to do...

Emmanuel

mdevaney
Super User
Super User

@ngreen 

From what I can tell you have 2 screens:

 

Screen1:  Always appears.  Holds the button to navigate to Screen2

Screen2:  Appears only when conditions are met on Screen1.

 

Write the following code in the OnStart property of your app.

 

Set(ShowScreen2,"No")

 

Then in the OnSelect property of the button on Screen1 write the following code

 

Set(ShowScreen2,"Yes");Navigate(Screen2,None)

 

The OnStart property will ensure your variable always intializes as "No".  We use a SET variable allows you to store a value globally.  That means the value remains stored even as the user progresses to other screens.  In this case it is an ideal alternative to UPDATECONTEXT for the reasons you have already mentioned.

 

Then later on you can submit the ShowScreen2 variable to the proper column whne the user submits the form.

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

 


@R3dKap wrote:

Hi @ngreen,

I suggest that in the OnSelect event of your button you set a variable (let's call it gloButtonPuhsed) to true.

Then, right after submitting your data to SharePoint, reset your variable gloButtonPushed to false.

Would that work for you ? Or maybe I didn't catch up what you're trying to do...

Emmanuel


How would you reset the variable outside of the screen though? UpdateContext doesn't work if you aren't on the page. Reset doesn't work with variables. My submit button is on a different screen.

Awesome! Set is the function that I was missing. Thank you so much! I don't know why I forgot about it, but it works exactly as I need. Thanks again for helping me solve another one of my questions

@ngreen 

No problem dude!  Always happy to help.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,589)