Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

JIRA Customfield with autocomplete

Cub1x November 21, 2016

I'm trying to create a single select JIRA custom field with autocomplete. I try to describe my problem.

What I want:
-Instead of a GenericTextCFType I want a single-select or autocomplete option, which gives me the values from a database, as soon as I enter a project name. So there is no need to copy paste the project id and it would be way more user-friendly.
-As soon as I entered a project id, it should only display work packages which are connected to the project (and not every work package in the database)

What I got so far:
-A plugin where I manually add the project id and work package id, it also checks if it's a correct combination in the database.
-Got the database connector which will also create an Array of all projects objects and an Array of all work package objects.

 

I also got a "guide", I refer to the answer from this post: https://answers.atlassian.com/questions/291628/answers/14195591 But I am stuck now.

His Car Array is equal to my project Array, but I have no clue about the methods getVelocity, createValue and updateValue and I am struggling with the .vm files.

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
KarolinaV November 21, 2016

I would recommend you to read this: http://docs.oracle.com/html/E48376_01/Content/Technical%20Reference/Velocity_Templates_DG.htm

And if you want to go a bit further: http://velocity.apache.org/engine/1.7/user-guide.html

But basically what happens is that whenever you create a custom field you extend it from an existing field type (from your example: GenericTextCFType) that has the method getVelocityParameters(..) which returns a map. This means that whatever you put in the map will be visible from your velocity template and you can call it by its key. 
So for instance you have:

@Override
    public Map<String, Object> getVelocityParameters(Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem)
    {
        Map<String, Object> params = super.getVelocityParameters(issue, field, fieldLayoutItem);
	.....
        params.put("projects", allProjects);
 	.....
        return params;
    }

In your velocity template you can just call the $projects variable and it will return whatever value the allProjects contains.
And I'm assuming that with the get/update value you mean the use of the $value variable? (which should be clear with the above explanation)

TAGS
AUG Leaders

Atlassian Community Events