Hi guys,
We wish to sort cards in the planning board according to our own custom field, which we have developed. In order to do this, the user must first modify the context in the planning board and go to the "Sorting" tab (as show in pic 1). The problem is that the sorting tab only shows certain custom fields in the list, as I can not see our own custom field called "Sort Key" in this list.
The custom field we created is a very simple custom field and its purpose is to sort issues in order (in the issue navigator) with parents and subtasks underneath each other, regadless of when a subtask was created.
For example, if a user sorts the issue navigator by issue key, some of the subtasks would display later in the results, because the subtask was created much later (and thus receiving a bigger issue key). However, when issues are sorted according to our sort key, subtasks appear under the respective parent level issue (vice versa when order is DESC) regardless of when the actual subtask was created. The Sort key is a combination of the parent level issues key and a number value of the subtask's key.
Example: We have parent level issue FB42-12 which has a subtask FB42-21. FB42 is the key for our project. Sort key for the parent level issue is FB42-12 and for the subtask FB42-12-21.
The source code for this custom field is as follows:
package com.customer.jira.remark.plugin.customfield; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.customfields.impl.CalculatedCFType; import com.atlassian.jira.issue.customfields.impl.FieldValidationException; import com.atlassian.jira.issue.fields.CustomField; public class SortField extends CalculatedCFType { public String getStringFromSingularObject(Object arg0) { return null; } public Object getSingularObjectFromString(String arg0) throws FieldValidationException { return null; } public Object getValueFromIssue(CustomField cf, Issue issue) { String issueKey = issue.getKey(); if (issue.isSubTask()) { String projectKey = issue.getProject().getString("key").toString(); String parentKey = issue.getParent().getString("key").toString(); return parentKey + issueKey.substring(projectKey.length()); } else { return issueKey; } } }
The question is, why does not the Custom Field show in the list in "Sort by" when editing the context?
Cheers,
Eric Salonen
Ambientia Ltd
Obsolete
There's also the change around sortable read-only fields that came with JIRA 6.0 https://developer.atlassian.com/display/JIRADEV/Preparing+for+JIRA+6.0#PreparingforJIRA6.0-CalculatedCFTypenolongerimplementsSortableCustomFieldbydefault
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello there.
Have you tried re-indexing?
I think sorting might be also connected to search index. Try setting a search template to the custom field (edit custom field in the administration section) and re-index again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi guys,
I would really love to get an answer for this question as it is baffling me quite a bit? Any help from the internets people?
Cheers,
Eric Salonen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need to implement it as a sortable field.
i.e.
public class SortField extends CalculatedCFType implements SortableCustomField {
...
public int compare(final Double customFieldObjectValue1, final Double customFieldObjectValue2, final FieldConfig fieldConfig) {
return customFieldObjectValue1.compareTo(customFieldObjectValue2);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
Thanks for you reply mate. I completed the following function for implementing the SortableCustomField:
public int compare(final String customFieldObjectValue1, final String customFieldObjectValue2, final FieldConfig fieldConfig) {
return customFieldObjectValue1.compareTo(customFieldObjectValue2);
}
Is this correct? The field is still not visible in the Sort By view in GreenHopper.
Any help still left?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi everybody,
Is there anybody that con confirm my question above?
Cheers,
Eric
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does it implement "sortable field" as well? That's worked for my code, I don't know if there's something else I've missed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
Thanks for the reply, yes it does implement the Sortable field as well, same way as in your example. Hmmm, I wonder what it might be....
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.