+ Start a Discussion
John MunzJohn Munz 

How do I get the next occurrence of a Recurring Holiday?

I was able to find the documentation about the Holiday Object (https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_holiday.htm), but I've noticed that when there is a recurring holiday, there is not a field that will show the next occurrence of the Holday. It will show the first time that activity was added in Salesforce in the ActivityDate field, but is there a field, or formula, I can use to get the next occurrence of the Holiday?
AbhishekAbhishek (Salesforce Developers) 
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 the start date and forever iteration, it will increment value till the 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 the list of all recurring holidays.

and call the above function on each list item.


For further reference, you can check this discussion (https://salesforce.stackexchange.com/questions/158547/recurring-holidays-exclude-holidays-between-two-dates)too.


Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks.