Calculate Days Elapsed Post Function
The Traffic Light custom field can be used in 2 ways:
For continuous tracking from the start date to keep on incrementing the days elapsed without a known end date
For grading the performance at the end by calculating the days elapsed with a known start and end date
Both can be done with the Calculate Days Elapsed for Traffic Light Post Function which initialises the information required for tracking the day elapsed.
Prerequisite
Besides a Traffic Light custom field, there should also be a configuration to define the traffic light mappings.
Refer to steps here to create a Traffic light custom field, and/or configure the Days Mapping.
Adding the Post Function
For the basics on setting up a workflow, please refer to Jira's documentation on configuring workflows
To modify an existing workflow to include the Calculate Days Elapsed Post Function,
Select the workflow transition to perform the calculate days elapsed post function
Click on Add post function and add a Calculate Days Elapsed for Traffic Light post function.
Publish the workflow
Some Technical Details to Note
When the post function is added in the Create transition, the Traffic Light post function needs to be placed before the "Creates the issue originally." post function for it to work.
In Set/Accumulate mode, if either the Start or End Date custom field(s) is updated by the post function, please ensure that the Calculate Days Elapsed for Traffic Light post function is placed after the update of the date field post function.
Please ensure the workflow is designed such that the End Date should not be earlier than the Start Date. Otherwise it will be considered as 0 day elapsed.
Special Case: if the End Date = Current Date and it is earlier than the Start Date, it will show as 0 day until the day the issue elapses the Start Date and the Traffic Light SLA will start incrementing
If a Traffic Light has Stopped (i.e. the Start and End Date time are known or Stop mode), the Traffic Light will no longer update until another Post Function triggers any change to it.
If a Traffic Light is still Running (i.e. End Date = Current Date or Start or Resume mode) and the issue's edited fields are used in the Traffic Light's JQL condition mapping, then the traffic light color might change if it matches another JQL condition.
If an issue cannot match any mapping conditions due to an edit, the Traffic Light becomes White color since the color cannot be determined. The color can be corrected if the JQL mapping condition changes or the issue is corrected.