In this example, we exclude weekends
You could extend the code to account for public holidays. The RTA Low Value code uses a similar process you may wish to examine.
Code: Select all
QUESTION( "After how many working days do you want to send the client satisfaction survey?" , "number" ) v-working-days = return-value #initialise counter for how many working days have passed so far in our loop v-found = 0 #initialise couter for loop. The value of this counter will be the number of CALENDAR days that correspond to the number #of working days requested v-loop = 0 #iterate over a loop until we have counted the required number of working days WHILE v-found < v-working-days DO #advance the counter v-loop = v-loop +1 #what is the date in v-loop days time? v-date-to-test = DATE-FROM-TODAY( v-loop ) #work out what day of the week this date is dayofweek = WEEKDAY( v-date-to-test ) IF dayofweek = "Saturday" OR dayofweek = "Sunday" THEN # weekends don't count towards working days ELSE # this is a working day - add one to our counter for how many working days we have found v-found = v-found + 1 END END #v-loop has counted how many calendar days are needed to give the required number of working days # now send email for v-loop days time DIARY AN ACTION AFTER (v-loop) DAYS (SEND-E-MAIL) WITH TEMPLATE (CL123) DIARY TO (CLIENT) DIARY AT (MAIN) DIARY DETAIL (Client Satisfaction Survey) DIARY FOR (Current Case Handler) CATEGORY (0) CASE ( CURRENT-CASE )