cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dinzey
Regular Visitor

Disable Button when counter hits a certain number

Hi,

 

I am trying to create a check in script for our office's

Each office can only have 30 workers on location due to COVID limitations set by our government.

 

I have already made a list + check in button.

The app is showing people who checked in using the app.

I also created a counter that triggers whenever a check in happens and also deletes it when a colleague checks out.

Now i wish to utilize the counter to disable the check in button so that check-ins are no longer possible when the threshold of 30 check-ins has been met.

 

Current code i tried using:

If(
Label_Counter.Text = "30";
DisplayMode.Disabled;
DisplayMode.Edit
)

The code is not giving me the results i want, sadly the button remains invisible.

 

The Code that the counter is using:

Value(CountIf(SPList; Checkin="Yes"))

 

Please help.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Drrickryp
Super User II
Super User II

Hi @Dinzey 

You can use UpdateContext({counter:counter+1}) to keep track of the number of times a button is clicked. Set the Visible property to counter< 30. You can reset it to 0 in the OnVisible property of the screen.

View solution in original post

This script looks only at the amount of times the check in button is pressed it does not check the counter itself. so if some one checks out the counter will remain on its current number of times the button is clicked.

 

Ok so i managed to use ur code in a different way for the check out button

 

Onselect Check in button code

UpdateContext({counter:counter+1})

Visible Check in button code

counter< 30

Onselect Check out button code

UpdateContext({counter:counter-1}) 

 

This actually works thanks for your advice!

View solution in original post

7 REPLIES 7
classicman
Regular Visitor

Couple of questions:

 

1) Are there two buttons to record the check-in/out process?

2) Does the user stay in the app during the check-in/out process?

3) If yes to the second question, are you refreshing the datasource referenced in your app to reflect the number of check-ins?

Drrickryp
Super User II
Super User II

Hi @Dinzey 

You can use UpdateContext({counter:counter+1}) to keep track of the number of times a button is clicked. Set the Visible property to counter< 30. You can reset it to 0 in the OnVisible property of the screen.

View solution in original post

1. Yes

2. Yes

3. The counter script automaticaly updates the number so i dont really understand Ur question about refreshing datasource?

My only reason for that question is to ensure that you are getting the number of check-ins with Label_Counter.Text.

 

What count is this field showing? You are either not updating the Checkin to "No" for your records upon check-out, or the current instance of the datasource is not being captured.

This script looks only at the amount of times the check in button is pressed it does not check the counter itself. so if some one checks out the counter will remain on its current number of times the button is clicked.

 

Ok so i managed to use ur code in a different way for the check out button

 

Onselect Check in button code

UpdateContext({counter:counter+1})

Visible Check in button code

counter< 30

Onselect Check out button code

UpdateContext({counter:counter-1}) 

 

This actually works thanks for your advice!

View solution in original post

classicman
Regular Visitor

Am I missing something? That’s the problem here, correct? How are you decrementing the counter back in SharePoint? (Cause that’s what should be happening)

Yes but the button needs to reappear once the amount of people on location are below 30.

This wasn't happening with just the onselect code for the check in button 😛

had to use that same code for the checkout button and that works like a charm, thanks!

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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,512)