I have tasks that need to be scheduled to run on specific days of the week. Each day a task is scheduled to run, an assignment for that task needs to be created. I have a field that the user selects the schedule frequency (daily, weekly, Quarterly, etc...) The one I am having the most trouble with is the daily. When the frequency of daily is selected, a second field displays called dailyFrequency that allows them to enter check boxes S M T W T F S, which are numbered 1, 2 3, etc respectively. If they check boxes 2,3,4,5, 7 each week, I'm having trouble developing a strategy to determine the next due date for that task. I have 3 variables.

1. A variable called $days that lists the days of the week the user has selected like this: SortValues ( Task Group::dailyFrequency; 2; "English").

2. A variable called $today that is just get (currentdate).

3.A variable that determines the day of the week for today's date DayOfWeek ( $today )

If today is Sunday (day 7), the next value I want in that list is the 2 so that I can determine the next upcoming date based on the next day. I'm stuck like chuck. I keep thinking of extremely complicated calculations that take me in circles. Maybe I'm thinking about it all wrong. Any help is much appreciated!

If today is Sunday (day 7)

Wouldn't Sunday be day 1 not 7?

and thus 2 would be the smallest value larger than 1 (Sunday)?

Simplest way to extract that 2 would be a loop that looped through the values until you either ran out of values or reached a value greater than your current day of the week. This could be a looping script or a recursive custom function. If none of the values are greater than today (such as if today is Saturday, you'd detect that and return the first value.

So maybe you should think in terms of a script instead of a calculation though a recursive custom function could also be set up here.