Assistance Needed: Disable the edit on Field or Form

  • 19 September 2019
  • 3 replies
  • 7 views

Badge +2

Hi, 

 

I wondering if you have any suggestion on how to disable a field or form during edit when a selected date is less than 24 hours of the current date. 

 

Background: Its a reservation form that let's users submit a request by filling out a couple of fields including a "date of reservation" (date picker without time) once done they send it and then the item is saved on the list. 

 

Intention: Lock the submitted request/item so that when the users attempts to edit it on the same date of the reservation, it won't let them make last minute changes.

 

I've read somewhere that I can use a calcuated expression however, I'm not exactly sure what formula to use. 

 

Appreciate any help! Thank you! 


3 replies

Userlevel 6
Badge +22

HI,

 

As you are only using the date what you are saying is that you need the date control disabled on the day of the reservation and the day before.

Apply the following rule to your date control.

and(lessThan(dateDiffHours(Current Date,Rdate),25),Is Edit Mode)

Rdate is the name of the date control I used.  Use the reference for the name of your date control instead.

What the rule is saying is If its less than 25 hours between the current date and the date in the control and the form is in edit mode disable the control.

The control will disable for the current day and the day before.

I have attached a sample Responsive form that demonstartes this.  Just connect the date control to your date column in the SharePoint list or test it unbound.

Badge +2

Thank you for taking the time to help and explain. I will definitely test it out and get back to you asap. 

Badge +2

I've been testing the rule you've provided and initially I was met with "an error occured during ajax call". I checked my named control (Rdate is the one you used) and I set the format to "Date and Time" as I previously set it to date only. 

 

Furthermore, I had to make one rule for each control as I would encounter the same error above if I tried to apply one rule to other controls. 

 

All in all it was an awesome help! I really appreciate it! Thank you so much!

Reply