Is there a creative way to schedule a workflow to ...
# general
l
Is there a creative way to schedule a workflow to run on the first BUSINESS day of each month (disregarding holidays)? Since it is not possible to define this on the workflow schedule, I'm trying to achieve it by scheduling the workflow on a daily basis. In the saved search used in the workflow, I'm trying to only return results on the first BUSINESS day of the current month which I'm also struggling with. Not sure if this will even work.
t
Why you want to do this in workflow rather than Map/Reduce script?
m
Maybe use a criteria like this in your saved search and your another criteria CASE WHEN TO_CHAR({today}, 'DD') = '01' THEN 1 WHEN TO_CHAR({today}, 'DY') = 'SAT' AND TO_CHAR(ADD_MONTHS({today}, -1), 'DD') = '31' THEN 1 WHEN TO_CHAR({today}, 'DY') = 'SUN' AND TO_CHAR(ADD_MONTHS({today}, -1), 'DD') IN ('30', '31') THEN 1 ELSE 0 END continue to use the workflow schedule which runs every day but no results will be if it is not the 1st day of the working month
l
@Tyn Guardian, I actually don’t know how to create scripts.
@Marc thank you. Honestly, I don’t quite understand the logic when combined together. Like how will it return results only if today is the first business day of the month?
m
The formula checks to handle different scenarios around the start of the month like your want If today is the 1st and it’s not a weekend, the first condition will return 1, indicating a business day. If the 1st is a weekend, the formula still returns 0 for that day. But it returns 1 on the next Monday (which could be either the 2nd or 3rd), considering it as the first business day of the month
l
Should the first WHEN statement be like where we add a criterion that it’s also not a Sat or Sun? WHEN TO_CHAR({today}, ‘DD’) = ‘01’ AND TO_CHAR({today}, ‘DY’) NOT IN (‘SAT’,‘SUN’)
m
CASE WHEN TO_CHAR({today}, 'DD') = '01' AND TO_CHAR({today}, 'DY') NOT IN ('SAT', 'SUN') THEN 1 WHEN TO_CHAR({today}, 'DY') = 'MON' AND TO_CHAR(ADD_MONTHS({today}, -1), 'DD') IN ('30', '31') THEN 1 ELSE 0 END
honestly I haven't tested the formulas But it’s just an idea
l
thanks anyway. this is a good start.