We will explain how to implement a validation for preventing work logs with a beginning date before a time limit in the past.
In particular, we will explain how to avoid work logs where the associated date is earlier than 10 days in the past, i.e., if we are on 25th march, today we only allow work logs with 15th march or later as beginning date.
Enforce work logs through transitions
First we need to enforce users to log all the work using transitions in our workflows, instead of using "Log Work" operation at the issue screen. To do it we will:
Administration > Add-ons > Manage add-ons > Filter by "System" > Issue Operations Plugin > Disable module "View Issue Ops Bar Work Link"
Typically you will add this transition to "In Progress" status, but you can add this transition to all statuses easily using a global reflexive transition.
You can use conditions or validations to limit who can execute these transition, and thus who can log work.
Now we only need to insert Boolean Validator with math, date-time or text-string terms in "Log Work" transitions using the following configuration:
Boolean expression used is: datePart({00057}, LOCAL) - datePart({00166}, LOCAL) <= 10 * {DAY}
Note that:
Once all the post-functions have been inserted, transition "Log Work" will look like this:
If you want to limit valid work logs to dates within current week you should use any of the following validations:
Weeks begin on Sundays
dayOfTheWeek({00057}, LOCAL) <= (datePart({00166}, LOCAL) - datePart({00057}, LOCAL)) / {DAY} AND (datePart({00166}, LOCAL) - datePart({00057}, LOCAL)) / {DAY} <= 7 - dayOfTheWeek({00057}, LOCAL)
Weeks begin on Mondays
dayOfTheWeek({00057}, LOCAL) != {SUNDAY} ? (2 - dayOfTheWeek({00057}, LOCAL) <= (datePart({00166}, LOCAL) - datePart({00057}, LOCAL)) / {DAY} AND (datePart({00166}, LOCAL) - datePart({00057}, LOCAL)) / {DAY} <= 8 - dayOfTheWeek({00057}, LOCAL)) : (-6 <= (datePart({00166}, LOCAL) - datePart({00057}, LOCAL)) / {DAY} AND (datePart({00166}, LOCAL) - datePart({00057}, LOCAL)) / {DAY} <= 0)