66
Views
7
Comments
Block dates based on condition

Hi Guys 
I have a requirement that i need block calendar dates based on condition as I'm using input date picker

were the requirement is that we need  book a slot for photographer for photoshoot so  based on business hours 

we have defined business hours i.e. weekstart,weekend & business holiday 

on weekstart dates should be enable until weekend den remaining dates should be disabled 

on business holidays date should be disabled in calendar

so I'm quite stuck with this implementation 

please help me with this guys

 thanks advance



image (11).png
image (12).png
2022-12-30 07-28-09
Navneet Garg

Please check following discussion. It might help you

https://www.outsystems.com/forums/discussion/87400/outsystems-ui-disable-dates-on-date-picker-in-outsystems-ui-version-2-9-0/

Also check the oml file you can use DisabledDates (List of dates for the disabled days.) to disable specific dates. You need to calculate the date before loading the date picker and pass that list to the component.

DatePicker.oml
UserImage.jpg
Anush Kumar

@Navneet Garg Thanks for your help I'm looking out for above requirement 

UserImage.jpg
Anush Kumar

Thanks for input as in this discussion dey have used dates to block 
as we are looking date & day because we have define business hours using days not date 
please suggest me on this 


2025-07-22 10-30-27
Mandar Deshpande

Hi @Anush Kumar 

Since you need business hours defined by days (Mon–Sun) and not by specific dates, while holidays are date-based; you can go with below approach:

1. Use BusinessHours entity (this would be day based) with Attributes:

    DayOfWeek (Integer 1–7), IsWorking (Boolean), StartTime (Time), EndTime (Time)

2. Use Holidays entity (this would be Date-based)

    HolidayDate (Date)

3. Now, when user opens calendar, for each visible date:

  • Get DayOfWeek(date)
  • Check BusinessHours[DayOfWeek].IsWorking; if No then disable date.
  • If yes then check Holiday table; if exists then disable date.
  • Else then enable date

4. Use a client action to compute disabled dates. DisabledDates would be Empty List initially and post calculation bind DisabledDates to your Date Picker.

Hope this helps.

2023-10-16 05-50-48
Shingo Lam

Its nice approach. I notice the question was asked on Apr 9, Idk whether @Anush Kumar is still keen on this or not 

2025-08-07 06-30-56
Amit J
Champion

Use logic instead of hard-coding the Date Picker.

Disable weekends by checking the weekday (allow only Monday to Friday).

Store business holidays in a BusinessHoliday entity.

Before loading the Date Picker, fetch holidays and pass them as DisabledDates to the Date Picker component.

This way, weekends and holidays are disabled dynamically and only valid business dates remain selectable.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.