I've created a scripted field called Work Effort Progress, but I'm not able to sort (ASC or DESC) on this field in the Issue Navigator unless I include "Work Effort Progress" is not EMPTY in the JQL. I don't think that I should need to do this because none of the fields have an empty value (i.e. "Work Effort Progress" is EMPTY doesn't return any issues at all). I've re-indexed multiple times and the issue is still occurring.
Here is the script I'm using.
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Category
import com.atlassian.jira.config.SubTaskManager
SubTaskManager subTaskManager = ComponentManager.getInstance().getSubTaskManager();
Collection subTasks = issue.getSubTaskObjects()
Double timeSpentTotal = 0
Double remainingEstimate = 0
Double progress = 0
if (subTaskManager.subTasksEnabled && !subTasks.empty) {
subTasks.each {
if (it.getTimeSpent() != null) {
timeSpentTotal += it.getTimeSpent()
}
if (it.getEstimate() != null) {
remainingEstimate += it.getEstimate()
}
}
}
else if (!subTaskManager.subTasksEnabled || subTasks.empty) {
if (issue.getTimeSpent() != null) {
timeSpentTotal = issue.getTimeSpent()
}
if (issue.getEstimate() != null) {
remainingEstimate = issue.getEstimate()
}
}
if (timeSpentTotal > 0) {
progress = ( timeSpentTotal / ( timeSpentTotal + remainingEstimate ) ) * 100
}
return progress.round(2)And here is my custom template (I added a pseudo progress bar far a visual representation of progress):
#if($value > 0.01 && $value <= 10)
<div><strong>[<span style="color:green;font-weight:bolder">></span></strong>>>>>>>>>><strong>]</strong> $value%</div>
#elseif($value > 10 && $value <= 20)
<div><strong>[<span style="color:green;font-weight:bolder">>></span></strong>>>>>>>>><strong>]</strong> $value%</div>
#elseif($value > 20 && $value <= 30)
<div><strong>[<span style="color:green;font-weight:bolder">>>></span></strong>>>>>>>><strong>]</strong> $value%</div>
#elseif($value > 30 && $value <= 40)
<div><strong>[<span style="color:green;font-weight:bolder">>>>></span></strong>>>>>>><strong>]</strong> $value%</div>
#elseif($value > 40 && $value <= 50)
<div><strong>[<span style="color:green;font-weight:bolder">>>>>></span></strong>>>>>><strong>]</strong> $value%</div>
#elseif($value > 50 && $value <= 60)
<div><strong>[<span style="color:green;font-weight:bolder">>>>>></span></strong>>>>>><strong>]</strong> $value%</div>
#elseif($value > 60 && $value <= 70)
<div><strong>[<span style="color:green;font-weight:bolder">>>>>>></span></strong>>>>><strong>]</strong> $value%</div>
#elseif($value > 70 && $value <= 80)
<div><strong>[<span style="color:green;font-weight:bolder">>>>>>>></span></strong>>>><strong>]</strong> $value%</div>
#elseif($value > 80 && $value <= 90)
<div><strong>[<span style="color:green;font-weight:bolder">>>>>>>>></span></strong>>><strong>]</strong> $value%</div>
#elseif($value > 90 && $value < 100)
<div><strong>[<span style="color:green;font-weight:bolder">>>>>>>>>></span></strong>><strong>]</strong> $value%</div>
#elseif($value == 100)
<div><strong>[<span style="color:green;font-weight:bolder">>>>>>>>>>></span></strong><strong>]</strong> $value%</div>
#else
<div><strong>[</strong>>>>>>>>>>><strong>]</strong> 0.0%</div>
#endI can search on this field just fine and everything else about this field works wonderfully except for the sorting capabilities. When I try to sort, I get this error message:
"Error occurred communicating with the server. Please reload the page and try again."
If I add in the JQL mentioned above, I can sort just fine. Any ideas on what might be causing the error or where I can look to try to diagnose the issue? Thanks for your help!