Solved

Restrict specific dates

  • 15 November 2022
  • 3 replies
  • 16 views

Hi All,



Trying to figure out on how to Restrict specific Dates in the Leave Form. in a month there some days that is blocked it will invalidate if they select the Restricted date. and if the Restricted date are included in the selected date range. for example, if date 11/17/2022 is Restricted it will invalidate this selection and will not be able to submit the form.





 



thank you!

icon

Best answer by Jake 21 November 2022, 11:19

View original

3 replies

Userlevel 3
Badge +8

Hi @UnknownJJ





This is an interesting one as it might be harder to dynamically work with the dates than it is to actually kick the validation.





First it is important that we get the invalid date back as a datetime, in my form I have used a control for this as below but you could also use a lookup to a Sharepoint list that stores invalid dates (this will probably be the hardest part as if there are multiple dates you'll need to find a way to maintain that).









I have created a single simple rule on the end date control that checks if the invalid date is less that or eq end date and greater than or eq start date.









Then to make sure the validation kicks off on both date/time controls click on 'view all rules' at the top.









Select select the start date control and click the ellipses on the rule and click add to selected controls, now the same rule is applied to 2 controls.









Rule code is as follows:





and(lessThanOrEqual([Invalid Date],[End Date]),greaterThanOrEqual([Invalid Date],[Start Date]))





As you can see below if i choose a date that falls in the range it invalidates and If I don't it allows me to submit.











Hi Jake,



I tried with this solution and this works fine as long as we can make invalidation works. thank you so much!

Badge

Would love to see more examples of calculated/dynamic dates (for example, default date is [Today]+3 days, and user can’t select date before that future timeslot, either in a formula on the control or in as validation rule. 

Reply