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> #end
I 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!
I used the following field code:
def modulus = issue.id.mod(4) modulus == 0 ? null : modulus as Double
and the sorting worked ok, except it sorted them in the order null, 3, 2, 1. Which is not intuitive to me.
If you're getting an error there should be a stack trace... although it might be truncated. Can you find it and post it?
Hi, Jamie - without making any changes to my field or anything today, I see that my field is sorting correctly. Not sure why it's working now and wasn't before. After creating the field, I re-indexed and checked, but it didn't work then. It is now! Appreciate your input and quick responses - thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Jamie - this scripted field is using a Number range searcher.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Which indexer/searcher is the custom field configured with?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.