Adding Holidays to Date Field

To add holidays to the date field, perform the following steps:

  1. Specify the holidays in the form's listener JS file. For example, the following code snippet adds three holidays to the data component:

    canvas.form.HOLIDAYS = Class(canvas.Observable, 
    {
        constructor: function (config) 
    	{
            this.fm = config.fm;
        },
        
    	registerHandlers: function () 
    	{
    		this.fm.registerHandler(CFEC.POST_FORM_RENDERER, function(fm) 
    		{
    			var bankholidays =  
    			[{
    				"dates":  // The date should be in 'DD/MM/YYYY' format.
    				[{
    					date : "15/08/2019",
    					text : "Independence Day"  // Mouse-over text
    				},
    				{
    					date : "06/09/2019",
    					text : "Founders' Day"  // Mouse-over text
    				},
    				{
    					date : "27/10/2019",
    					text : "Diwali"  // Mouse-over text
    				}],
     
    				"cssClass" : 'holidaycolor'  // 'holidaycolor' is the name of the CSS class.
    			}];
    
    			fm.setHolidayDates(bankholidays,"BANK_CALENDAR");  // "BANK_CALENDAR" is item ID of the Date field.
    		});
        }
    });
    
    CFLR.registerListener("HOLIDAY", canvas.form.HOLIDAYS);  // "HOLIDAY" is the form ID.
  2. Create the CSS class for highlighting the holidays in the date tool. For example:

    .holidaycolor
    {
    	color: blue;
    }