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
Super User

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
Super User

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.

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!

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
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (3,123)