Clone wiki

JIRA Workflow Toolbox / amazing / Limit Past Dates For Current Work Logs

Limiting Valid Dates for Work Logs

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 WORKLOGS 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:

1. Remove "Log Work" option from operation menĂº: Administration > Add-ons > Manage add-ons > Filter by "System" > Issue Operations Plugin > Disable module "View Issue Ops Bar Work Link"

2. Create a screen with only one field: "Log Work". You can call it "Work Log in Transition".

3. Add reflexive transitions called "Log Work" in the statuses of our workflow where we want users to be allowed to log work, and we associate them screen "Work Log in Transition", created in previous step. These transitions have the same status as origin and destination, leaving the issue in the same status, but showing the user a screen where they will be able to log work.

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.

VALIDATION:

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 validation configuration

Boolean expression used is: datePart({00057}, LOCAL) - datePart({00166}, LOCAL) <= 10 * {DAY}

Note that:

  • {00057} is code for numeric value of virtual field "Current date and time".
  • {00166} is code for numeric value of virtual field "Date and time of work logged in transition".

Once all the post-functions have been inserted, transition "Log Work" will look like this:

Boolean validation configuration

Other validations:

If you want to limit valid work logs to dates within current week you should use any of the following validations:

1) Weeks begin on Sundays

1 - dayOfTheWeek({00057}, LOCAL) <= (datePart({00166}, LOCAL) - datePart({00057}, LOCAL)) / {DAY} AND (datePart({00166}, LOCAL) - datePart({00057}, LOCAL)) / {DAY} <= 7 - dayOfTheWeek({00057}, LOCAL)

2) 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)

Related Examples:

Updated