Search code examples
salesforceapex-codevisualforceforce.com

How to handle recurring holidays in Salesforce


In salesforce I can create recurring holidays and based on that in my apex class I want to check whether the current day is holiday or not.

This works fine with normal non recurring holiday. But when I create recurring holiday there is no way to find whether current date will fall on any of the recurring dates.

the holiday object's ActivityDate returns the start date of holiday.

Does anyone have checked the recurring holidays in past for salesforce?


Solution

  • Here is how i would approach this.

    Create a function that will take parameters like RECURRENCESTARTDATE , RECURRENCEENDDATEONLY, RECURRENCETYPE, RECURRENCEINTERVAL, RECURRENCEDAYOFWEEKMASK, RECURRENCEDAYOFMONTH, RECURRENCEINSTANCE, RECURRENCEMONTHOFYEAR.

    Then this function will loop from start date and for ever iteration it will increment value till date is > today or date is > RECURRENCEENDDATEONLY

    in this loop you can check if today's == date calculated above.

    once this function is ready pull out list of all recurring holidays.

    and call above function on each list item.

    let me know if you have any questions.