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

Sharepoint list subtract available slots based on dates and time slots

Hi, pretty new on PowerApps. But got a project, needs to keep track COVID-19 testing slots, 40 slots each day, 10 testing every two hours, from 8am -5pm. I was thinking to have two sharepoint lists. One collecting client info, the other list of dates, time slots and available slots. When one appointment is booked, it subtracts 1 from that time slot, I.e. from 10 to 9, till available slots becomes 0. What is the best approach ? Flow? Or use patch, updatecontent?

thanks!

20 REPLIES 20

I attached the the screen for date and time slot, but these two are from second list, I added your code, the available slot number didn't go down, but it didn't give any error message.

 

Patch(
COVID19Screening,
Defaults(COVID19Screening),
'Initial Form'.Updates,
EditClientForm.Updates,
ChooseDateForm.Updates
);
NewForm('Initial Form');
NewForm(EditClientForm);
NewForm(ChooseDateForm);
UpdateIf(
COVID19TestAvailability,
TimeSlot = DataCardValue62.Selected.Value &&//xxx depends on the control type
DateDiff(
TestDate,
DataCardValue61.SelectedDate,
Days
) = 0,
{AvailableSlot: AvailableSlot - 1}
)

Sorry, I meant, those two controls are from client list, not timeslot list. 

Thanks @lras120265 ,

Firstly forget about the Patch for the moment - that is a completely separate operation.

Put this on a button and see it it works

UpdateIf(
   COVID19TestAvailability,
   TimeSlot = DataCardValue62.Selected.Value &&
   DateDiff(
      TestDate,
      DataCardValue61.SelectedDate,
      Days
   ) = 0,
   {AvailableSlot: AvailableSlot - 1}
)

If not, put this in the Text of a label (anywhere on the screen) to see if you can the the current AvailableSlot number

Lookup(
   COVID19TestAvailability,
   TimeSlot = DataCardValue62.Selected.Value &&
   DateDiff(
      TestDate,
      DataCardValue61.SelectedDate,
      Days
   ) = 0
).AvailableSlot

 As a matter of interest, where are you situated (I am in Queensland, Oz)?

View solution in original post

I am in North Carolina, US. 

Will work on this now. Need to get this piece working by tomorrow. Thanks again for your help and patience. I only studied PowerApps less than a couple of weeks.

OK @lras120265 ,

I assume you are about 7:15am Sunday where you are. I am 9:15pm Sunday and will be offline shortly.

Please send your questions and I will pick up in the morning.

My only concern is that if this is your first Power App, there are some basic concepts you should really learn before tackling something of this complexity. It is very important that you understand the functionality of what I provide, otherwise it will not be repeatable for you.

Having said that I understand the criticality of what you are doing here and will assist where I can.

Thank you so much for helping! It worked!! I was able to abstract 1 when making appointment till there is 0.

 

Now I am trying to figure out how to update the available slots number when the client wants to change appointment date and time slot. I created two labels to store original appointment dates, lbOriginalDate, lbOriginalSlot, so I can add 1 to original date and time slot, but these two label can't keep the value, when date changes, it changes with it. Would you please help me on this one too? Thank you for you kindness. I know I am really new to powerapps., still want to make it work to help people to do the testing.

 

LookUp(
COVID19TestAvailability,
TimeSlot = DataCardValue120.Selected.Value && DateDiff(
TestDate,
DataCardValue119.SelectedDate,
Days
) = 0
).TestDate

Hi @lras120265 ,

You would do this in two actions - have a "cancel appointment" simply adding 1 to the total then treat the new one as you do now.

Happy to help if you get stuck.

 

 

yeah, trying to add 1, but where to get original date and original appointment time? the date in dropdown and time slot are new date and time slot.

 

Thanks!

I figured it out: i can find the original date and time slot from gallery!!

 

UpdateIf(
COVID19TestAvailability,
TimeSlot = GalleryClientListing.Selected.'Time Slot'.Value &&//xxx depends on the control type
DateDiff(
TestDate,
GalleryClientListing.Selected.'Test Date',
Days
) = 0,
{AvailableSlot: AvailableSlot + 1}
)

@lras120265 ,

Does not the customer tell you? I think you might need a cancel appointment screen. This is more a process problem than a programming one.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (42,788)