How to create a new Custom Field Type

All Versions

JIRA 4.0 Beta Documentation

Since JIRA 3.0 you have been able to create your own Custom Field Types through the plugin interface. In this tutorial, we'll take a look at a few simple examples and explain how you can easily achieve this.

Before you start, you may also want to familiarise yourself with the JIRA Plugin Guide.

A note about changed interfaces
We're always endeavouring to make JIRA better with each release. This often leads to new improvements and changes to the public interfaces in major JIRA versions (e.g. 3.1 to 3.2). This guide has been updated for the latest JIRA release, so if you're building a plugin for a prior JIRA version, keep an eye out for notes about differences in the interface.

A Quick Custom Field Types Primer

There's a few things you need to understand before diving into custom fields. A custom field type can have three components.

  • Java Class encapsulating custom field logic
  • Resource templates for display of custom field
  • Module descriptor to enable the custom field module in JIRA

A custom field class extends the interface CustomFieldType. This interface provides methods to retrieve and store custom fields values. There are several extension points that are available to make creating new custom field types easier (e.g. CalculatedCFType, AbstractSingleFieldType, AbstractMultiSettableCFType). It is also possible to extend existing custom field types to add functionality (e.g. A currency type extending NumberCFType).

The second component are the resource templates which renders the custom field. There are four view types available, each representing a different context to render the custom field.

  1. view - basic read-only view of the value (e.g. view issue, move issue confirm screen)
  2. column-view - read-only view for displaying in the issue navigator. will default to view if omitted
  3. edit - renders the edit widget for the custom field (e.g. edit issue, edit defaults)
  4. xml - xml view of the value (e.g. rss, xml views)

Linking the Java code and rendering views are the plugin-module descriptors in your atlassian-plugin.xml. They allow JIRA to recognise what custom fields are available to the system and how to render them.

Example module descriptor
<atlassian-plugin key="com.atlassian.jira.plugin.customfield.example" name="JIRA Customfields Examples Plugin">
<plugin-info>
<description>Customfields Examples Plugin.</description>
<version>1.0</version>
<application-version min="3.3" max="3.3"/>
<vendor name="Atlassian Software Systems Pty Ltd" url="http://www.atlassian.com"/>
</plugin-info>

<customfield-type key="textarea" name="Free Text Field (unlimited text)"
class="com.atlassian.jira.issue.customfields.impl.TextAreaCFType">
<description>A multiline text area custom field to allow input of longer text strings.</description>

<resource type="velocity" name="view" location="templates/plugins/fields/view/view-basictext.vm"/>
<resource type="velocity" name="column-view" location="templates/plugins/fields/view/view-limited-text.vm"/>
<resource type="velocity" name="edit" location="templates/plugins/fields/edit/edit-textarea.vm"/>
<resource type="velocity" name="xml" location="templates/plugins/fields/xml/xml-basictext.vm"/>
</customfield-type>
</atlassian-plugin>

You can also take a look at the default custom fields that shipped with JIRA here.

Information about setting up a complete plugin development environment for a plugin can be found here.
You can compile the examples below in the same way.

Admin-only editable field

For the first example, we'll construct a custom field that is only be editable by JIRA administrators and appear as a plain text to others. This is a simple customisation of the shipped TextCFType custom field and can be done by change one edit template.

First, we need to add the module to the atlassian-plugin.xml.

...
<customfield-type key="admintextfield" name="Admin Editable Text Field"
class="com.atlassian.jira.issue.customfields.impl.TextCFType">
<description>A text field only editable by JIRA-administrators. Others will see only text.</description>
<resource type="velocity" name="view" location="templates/plugins/fields/view/view-basictext.vm"/>
<resource type="velocity" name="edit" location="templates/edit-jiraadminonlytext.vm"/>
<resource type="velocity" name="xml" location="templates/plugins/fields/xml/xml-basictext.vm"/>
</customfield-type>
...

A few points:

  • key must uniquely identify the module in this plugin file.
  • name & description are displayed when creating a new custom field instance

This module definition exactly matches that of a standard text field except for one line.

<resource type="velocity" name="edit" location="templates/edit-jiraadminonlytext.vm"/>

We are customizing the edit Velocity template so that it displays as a text box for an administrator but appears as uneditable text for others. Source for edit-jiraadminonlytext.vm is below.

edit-jiraadminonlytext.vm
#controlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters.noHeader)

#if ($authcontext.user.inGroup('jira-administrators'))
<input type="text"
name="$customField.id"
value="$!value" />
#else
#if($value && ! $value.equals(""))
#set ($displayValue = ${value})
#else
#set ($displayValue = 'N/A')
#end
<span title="This field is editable only by JIRA administrators">$!displayValue</span>
<input type="hidden"
name="$customField.id"
value="$!value" />
#end
#controlFooter ($action $fieldLayoutItem.fieldDescription $displayParameters.noHeader)

The above template checks if the user is part of group jira-administrators. If they are, display the text box, else display the value only as uneditable text.

There's a few points to note.

  • For what variables are available for a custom field you should check out the velocity context guide.
  • #controlHeader and #controlFooter provide each custom field with the appropriate label and surrounding HTML table tags. This is required for all edit templates.

And that's it, a new custom field type. Deploy the JAR, login as an administrator and then a normal user and try it out.



Logged in as an admin



Logged in as a non-admin

Last commented user calculated field

The next example deals with a Calculated Custom Field. Calculated don't actually store any values. You often want or need this when you want to search on fields not normally available in JIRA, but the information can be derived. In this case, we want to return the last user who commented on the issue, if they are not an administrator. We only want this field to be visible in the issue navigator and not the edit or view pages.

Coding the Custom Field Type

Before you implement the interface CustomFieldType you should check out the latest javadoc. A useful extension point for calculated custom fields is, unsurprisingly, CalculatedCFType, where only three methods need to be implemented (getStringFromSingularObject, getSingularObjectFromString, and getValueFromIssue). If you also choose to implement SortableCustomField you will need to implement compare() as well.

The key method used to retrieve the value of our custom field is getValueFromIssue.

public Object getValueFromIssue(CustomField field, Issue issue)
{
User currentUser = authenticationContext.getUser();
User lastUser = null;
try
{
List comments = actionManager.getComments(issue.getGenericValue(), currentUser);
if (comments != null && !comments.isEmpty())
{
Comment lastComment = (Comment) comments.get(comments.size()-1);
User commenter = lastComment.getUser();
if (!commenter.inGroup(JIRA_ADMIN))
{
lastUser = commenter;
}
}
}
catch (GenericEntityException e)
{
}

return lastUser;
}

Note that prior to 3.3, the method had a GenericValue as the issue parameter. If you're developing for those JIRA versions make sure you correct your method signatures.

The return type Object is also known as the Transport Object. In this instance it is of type User, but it could be any other type. The Transport type must remain consistent across all methods such as create, update and also the view and edit templates.

Wiring it together

Much like the previous example, we can reuse some of the the templates that ship with JIRA.

<customfield-type key="lastusercommented" name="Last user commenter"
class="com.atlassian.jira.plugin.customfield.example.LastUserCommentedCFType">
<description>This is a lookup field that displays the last commenter who is not a JIRA administrator</description>
<resource type="velocity" name="column-view" location="templates/plugins/fields/view/view-user.vm"/>
<resource type="velocity" name="xml" location="templates/plugins/fields/xml/xml-user.vm"/>
</customfield-type>

We can omit any resource types that we don't require. Thus both the edit and view templates are omitted here. The field should only appear when viewing through the issue navigator (column-view) and XML/RSS views (xml). The view user adds a link to the user details page and displays the full user name.



Fred is the last commenter



View in issue navigator

Enable Searching

The last commenter field in itself isn't all that useful. While we can see it in on the issue navigator, we can't search for a particular user who commented it last. Searching in JIRA 3 is handled by CustomFieldSearchers. Again several pre-configured searchers are available. You must ensure that the Transport Object are compatible between the custom field and the custom field searcher. Thus we can only use the UserPicker searcher since this is the only one that indexes User objects.

<customfield-searcher key="userpickersearcher" name="User Picker Searcher"
    i18n-name-key="admin.customfield.searcher.userpickersearcher.name"
    class="com.atlassian.jira.issue.customfields.searchers.UserPickerSearcher">
    <description key="admin.customfield.searcher.userpickersearcher.desc">Allow to search for a user using a userpicker.</description>
    <resource type="velocity" name="label" location="templates/plugins/fields/view-searcher/label-searcher-user.vm"/>
    <resource type="velocity" name="search" location="templates/plugins/fields/edit-searcher/search-userpicker.vm"/>
    <resource type="velocity" name="view" location="templates/plugins/fields/view-searcher/view-searcher-basictext.vm"/>

    <valid-customfield-type package="com.atlassian.jira.plugin.customfield.example" key="lastusercommented"/>
</customfield-searcher>

This is quite similar to the CustomFieldType definition. The tag valid-customfield-type is used to associate the searcher to any number of custom field types. Package refers to the atlassian-plugin key attribute at the top of a plug-in and and the key refers to the module/customfield key.

Now when you create/edit your Last User Commented custom field, you'll be able to select the User Picker as a search template. You can now search on the last commenter field in the issue issue navigator.

Important When you change a search template for a custom field, you may need to perform a reindex before the search will work correctly. This issue is being tracked at JRA-4641.



Searching enabled

Sorting in Issue Navigator

To enable sorting you simply need to implement the interface SortableCustomField

public class LastUserCommentedCFType extends AbstractCustomFieldType implements SortableCustomField

The interface simply extends Comparable, so you need to implement the compare method.

public int compare(Object customFieldObjectValue1, Object customFieldObjectValue2, CustomFieldConfig customFieldConfig)
{
return new BestNameComparator().compare(customFieldObjectValue1, customFieldObjectValue2);
}

The BestNameComparator is a simple helper type to facilitate comparing two users. You could just as easily write your own custom compare method.

Amazon search plugin

Lastly, a frivolous plug-in to give you some ideas on how to implement custom fields that perform remote look ups. Basically, we want a custom field that will take a text string and display a results from a search through the Amazon. There are several approaches to this, but by simplest solution is to treat the stored value as a simple text field and then add a viewHelper object that effectively transforms the string into the desired result.

Coding and Attaching the view helper

First we need to code our Amazon view helper. You can take a look in the source, but how it's been implemented isn't all that relevant. Once we have the view helper, we can pass this helper to the Velocity templates through the method getVelocityParameters

public Map getVelocityParameters(Issue issue)
{
Map map = new HashMap();
map.put("amazonSearchViewHelper", new AmazonSearchViewHelper());
return map;
}

The object AmazonSearchViewHelper is now accessible the velocity template. It has the method searchForBooks which returns a list of Books given some key words. We simply invoke this helper method in the template and display the results in a table.

#if ($value)
Results for search query "${value}" <br />

<table class="grid">
<tr>
<th>Title</th>
<th>Primary Author</th>
</tr>
#foreach ($book in $amazonSearchViewHelper.searchForBooks($value))
<tr>
<td><a target="_new" href="${book.link}">${book.title}</a></td>
<td>${book.firstAuthor}</td>
</tr>
#end
</table>
#end

You can utilise this same idea to display data from other remote systems, or even combine it with the readonly field to create your very own remote custom field.

Confluence Page Link custom field

This plugin is available here - and is not included in the jira-development-kit.

The 'Confluence Page Link' custom field plugin provides an example of implementing a custom field that performs a remote look up through XML/RPC..

This custom field provides a pop-up searcher - allowing the user to enter a search query that is executed over publicly accessible pages within a specified Confleunce instance. The user can select a result and the URL of thatpage is stored in the custom field - a simple text field. The Confluence instance to search against is specified in a properties file.

A new webwork action 'ConfluencePageBrowserAction' is required - allowing the popup window view to be associated with the action that performs and returns results from the Confluence page search.

The webwork action is registered in the atlassian-plugin.xml file as follows:

<webwork1 key="confluencepagebrowseraction" name="Confluence Page Browser Action" class="java.lang.Object">
<actions>
<action name="com.atlassian.jira.plugin.confluencelinker.ConfluencePageBrowserAction" alias="ConfluencePageBrowser">
<view name="success">/templates/confluence_page_browser.vm</view>
</action>
</actions>
</webwork1>

The ConfluencePageBrowserAction class is where the search logic is coded:

XmlRpcClient rpcClient = new XmlRpcClient(confluenceURL);
Vector xmlrpcResults = (Vector) rpcClient.execute("confluence1.search", makeParams(getSearchQuery(), 100));
if (xmlrpcResults != null)
{
earchResults = new ArrayList();
for (Iterator iterator = xmlrpcResults.iterator(); iterator.hasNext();)
{
Hashtable xmlrpcResult = (Hashtable) iterator.next();
searchResults.add(new SearchMatch(xmlrpcResult));
}
...

The Confluence page browser template displays the search query text box and the results:

#foreach ($result in $action.getSearchResults())
<tr onmouseover="rowHover(this)" onclick="selectLink('$result.getUrl()')">
<td>
<div class="borderedbox">
<b>Title</b>:   $result.getTitle()<br>
<b>URL</b>:     $result.getUrl()<br>
<b>Excerpt</b>: #if($result.getExcerpt())$result.getExcerpt() #else None #end
</div>
</td>
</tr>

The popup appears as follows:

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Mar 10, 2006

    Uldis Anšmits says:

    You don't have to worry about arguments in custom field constructor. Picocontain...

    You don't have to worry about arguments in custom field constructor. Picocontainer resolves constructor dependencies.

    ( customfield method parameters )

  2. Sep 17, 2007

    Tim Feeley says:

    Creating (in the hackiest way possible) a select dropdown that is editable by Ad...

    Creating (in the hackiest way possible) a select dropdown that is editable by Admins only

    Howdy.

    So, I doubt this is the correct way to accomplish this -- but i needed a quick hack in order to have a custom field type that is admin-editable only, but instead of a text box, is a drop down box. Being anti-JAVA, anti-Maven and generally anti-anything-that-makes-me-put-in-semicolons, I worked out this gem... Hope it helps as a starting point for some of you who want a select list that is disabled for all but admins, since I've seen that request a few times.

    /var/www/jira/atlassian-jira/WEB-INF/classes/templates/plugins/fields/edit/edit-adminselect.vm


    #controlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters.noHeader)
    
    #if ($authcontext.user.inGroup('jira-administrators'))
    <select name="$customField.id" id="$customField.id">
        #if (!$fieldLayoutItem || $fieldLayoutItem.required == false)
            <option value="-1">$i18n.getText("common.words.none")</option>
        #else
            <option value="">$i18n.getText("common.words.none")</option>
        #end
        #foreach ($option in $configs.options)
            <option value="$textutils.htmlEncode($option.value)"
                #if ($value && $value == $option.value)selected#end
                >$option.value</option>
        #end
    </select>
    
    #else
    
         #set ($displayValue = 'N/A')
    
         #foreach ($option in $configs.options)
              #if ($value && $value == $option.value)
                    #set ($displayValue = ${option.value})
              #end
         #end
    
        <span style="color: #666; border-bottom: 1px dotted #333;" title="This field is editable only by JIRA administrators">$!display$
        <input type="hidden"
               name="$customField.id"
               value="$!displayValue" />
    #end
    
    
    #controlFooter ($action $fieldLayoutItem.fieldDescription $displayParameters.noHeader)
    
    
    


    And then, in my infinite wisdom of hackery:

    /var/www/jira/atlassian-jira/WEB-INF/classes/system-customfieldtypes-plugin.xml
        <customfield-type key="select2" name="Admin Select List"
            class="com.atlassian.jira.issue.customfields.impl.SelectCFType">
            <description key="admin.customfield.type.select.desc">A single select list (admin editable only) with a configurable list o$
    
            <resource type="velocity" name="view" location="templates/plugins/fields/view/view-rawtext.vm"/>                 
            <resource type="velocity" name="edit" location="templates/plugins/fields/edit/edit-adminselect.vm"/>                  
            <resource type="velocity" name="xml" location="templates/plugins/fields/xml/xml-basictext.vm"/>
        </customfield-type>
    
        <customfield-searcher key="selectsearcher2" name="Select List Searcher"
            i18n-name-key="admin.customfield.searcher.selectsearcher.name"
            class="com.atlassian.jira.issue.customfields.searchers.SelectSearcher">
            <description key="admin.customfield.searcher.selectsearcher.desc">Search for values using a select list.</description>
    
            <resource type="velocity" name="search" location="templates/plugins/fields/edit-searcher/search-select.vm"/>
            <resource type="velocity" name="view" location="templates/plugins/fields/view-searcher/view-searcher-basictext.vm"/>
            <resource type="velocity" name="label" location="templates/plugins/fields/view-searcher/label-searcher-basictext.vm"/>
            <valid-customfield-type package="com.atlassian.jira.plugin.system.customfieldtypes" key="select2"/>
        </customfield-searcher>
    

    I hope this helps for those who actually have the time (and talent) to do this up right

    Have a lovely day, folks!

  3. Feb 04, 2008

    Mathieu GARAUD says:

    Hello, Where is the source code of this tutorial ? Thanks in advance, Mathieu

    Hello,

    Where is the source code of this tutorial ?
    Thanks in advance,

    Mathieu

    1. Aug 29, 2008

      Jeff Kirby says:

      The Calculated Custom Field example lacks. Here's what I came up. A huge thank...

      The Calculated Custom Field example lacks. Here's what I came up. A huge thank you to Uldis for his Picocontainer tip. Before I read that I was banging (ironically, that's the code word that appears in an image to submit this comment) my head against the desk trying to figure out where the mysterious authenticationContext and actionManager came from.

      import com.atlassian.jira.issue.Issue;
      import com.atlassian.jira.issue.comments.Comment;
      import com.atlassian.jira.issue.comments.CommentManager;
      import com.atlassian.jira.issue.customfields.impl.CalculatedCFType;
      import com.atlassian.jira.issue.fields.CustomField;
      import com.atlassian.jira.security.JiraAuthenticationContext;
      import com.opensymphony.user.EntityNotFoundException;
      import com.opensymphony.user.User;
      import com.opensymphony.user.UserManager;
      import java.util.List;
      
      public class CalculatedCustomField extends CalculatedCFType {
      
         private JiraAuthenticationContext authenticationContext = null;
         private CommentManager commentManager = null;
         private UserManager userManager = null;
      
         /**
          * Picocontainer should populate this
          * @see "http://confluence.atlassian.com/display/JIRA/PicoContainer+and+JIRA" />
          * @param authenticationContext authentication Context
          * @param commentManager comment Manager
          * @param userManager user manager
          */
         public CalculatedCustomField(JiraAuthenticationContext authenticationContext, CommentManager commentManager, UserManager userManager) {
            this.authenticationContext = authenticationContext;
            this.commentManager = commentManager;
            this.userManager = userManager;
         }
      
         public Object getValueFromIssue(CustomField field, Issue issue) {
            User lastUser = null;
            List comments = commentManager.getCommentsForUser(issue, authenticationContext.getUser());
            if(comments != null && !comments.isEmpty()) {
               Comment lastComment = (Comment)comments.get(comments.size() - 1);
               try {
                  lastUser = userManager.getUser(lastComment.getAuthor());
               }
               catch(EntityNotFoundException e) {
                  e.printStackTrace();
               }
            }
            return lastUser;
         }
      
         /** not sure what this does...doesn't ever seem to get called...but must exist */
         public String getStringFromSingularObject(Object customFieldObject) {
            return customFieldObject.toString();
         }
      
         /** not sure what this does...doesn't ever seem to get called...but must exist */
         public Object getSingularObjectFromString(String customFieldObject) {
            return customFieldObject;
         }
      }
      
  4. Mar 20, 2008

    Wim Deblauwe says:

    The example here uses: public Map getVelocityParameters(Issue issue) but t...

    The example here uses:

    public Map getVelocityParameters(Issue issue)
    

    but this method is deprecated and should be replaced by

    public Map getVelocityParameters( Issue issue, CustomField customField, FieldLayoutItem fieldLayoutItem )
    

    I think it would be good to update this page with this information.

    Also, does the AbstractCustomFieldType already includes something in the Map or is it best practise to create a new map and return that one as the example shows?

    regards,

    Wim

  5. May 30, 2008

    Jo-Anne says:

    Has anyone actually tried to follow the examples?  I am trying to create a ...

    Has anyone actually tried to follow the examples?  I am trying to create a admin only editable field.  I'm trying to follow the example given.  There are a few questions that haven't been explained.  Gotta keep in mine that a tutorial is so that you can learn it.  So I have found atlassian-plugin.xml, now amd I just supposed to add the lines given somewhere in the file?  Does it matter where?  Once I edit, jira-adminonlyedit.vm to have the lines given.  Then what?  The tutorial only says..."thats it"  There must be some way to get the information from the source directory into a running JIRA installation.  Obviously I am missing something here, but I don't know what.  If anyone is on this page, can you help?

  6. Jul 16, 2008

    carol paige says:

    Has anyone added a custom field that is a sum of many fields?  (10 values p...

    Has anyone added a custom field that is a sum of many fields?  (10 values potentially)

    1. Jul 25, 2008

      Vincent Thoulé says:

      Yes, I do it. See http://kaamelot.fr.free.fr/doc/3.1x.1.x/Functional-Features/C...
  7. Jul 16, 2008

    Ray La Valley says:

    Has anyone added a custom field that pulls in external data from elsewhere in th...

    Has anyone added a custom field that pulls in external data from elsewhere in their database (outside Jira tables)?  An example would be pulling in the IP address and phone extension for the reporter of an issue, where I maintain that information outside of the Jira application, and displaying that info in the Issue Navigator and the Issue Details views.

    I see above mention of CustomFieldType and CalculatedCFType which may be what I want , but where is this code executed from and how is it used?  Is there an example of how to (and where to) use this Java code?

    Thanks,

    Ray

    1. Jul 25, 2008

      Vincent Thoulé says:

      Almost ... Each time, I need to use other data as JIRA, I integrate the added Ta...

      Almost ... Each time, I need to use other data as JIRA, I integrate the added Table in the OFBIz Entity Model.
      Other possible solutions should be to perform all Database acces through JDBC ... Good luck.
      V.

  8. Aug 01, 2008

    Karsten Landwehr says:

    Hi guys,  can I do the same thing with Confluence? I want to display a tex...

    Hi guys,

     can I do the same thing with Confluence? I want to display a text field on a page where a user can enter a word. This should then be used in an WHERE clause of an SQL-Statement.

     It would be nice if someone can give me a guide for this or so.

    Regards

    Karsten

  9. Aug 29, 2008

    Jeff Kirby says:

    There's a few typos in the edit-jiraadminonlytext.vm Velocity template. If you ...

    There's a few typos in the edit-jiraadminonlytext.vm Velocity template. If you use the one in the tutorial above, then non-admin users will always see 'N/A' and the field will be deleted when they update any form. Here's a simpler template that works

    #controlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters.noHeader)
    
    #if($authcontext.user.inGroup('jira-administrators'))
       <input type="text" name="$customField.id" value="$!value" />
    #else
       <span title="This field is editable only by JIRA administrators">$!value</span>
       <input type="hidden" name="$customField.id" value="$!value" />
    #end
    
    #controlFooter ($action $fieldLayoutItem.fieldDescription $displayParameters.noHeader)
    

    I think it would be good to add an instruction to use the Atlassian JIRA Maven archetype generator, to then create a folder called src/main/resources/templates, and put edit-jiraadminonlytext.vm in there. Then when you can run mvn -Pplugin-debug to try it out.

  10. Aug 29, 2008

    Jeff Kirby says:

    Please provide more detail on the "user picker searcher" example for the "last u...

    Please provide more detail on the "user picker searcher" example for the "last user commented" custom field.  I added the <customfield-searcher> element as instructed but I can't see any evidence that it's providing a new feature to my JIRA instance.  Help.

    1. Sep 04, 2008

      Andrew Lui [Atlassian Technical Writer] says:

      Hi Jeff, Thanks for your comments. Could I ask you to provide further details o...

      Hi Jeff,

      Thanks for your comments. Could I ask you to provide further details on the problems you are experiencing with the <customfield-searcher> element?
      i.e. what are you trying to achieve with our example and what errors or unexpected behaviour are you getting?

      We are also looking at the example Velocity template, that you have commented on.

      Kind Regards,
      Andrew

      1. Sep 12, 2008

        Jeff Kirby says:

        My problem is that I don't know where to see the results or the benefit of the p...

        My problem is that I don't know where to see the results or the benefit of the plug-in.  What functionality is it providing?

  11. Nov 03, 2008

    Edward McColgan says:

    Is there an easier way to add a custom field that is invisible to all and only u...

    Is there an easier way to add a custom field that is invisible to all and only updated by an event listener plugin?  I could use a completely separate table, but it would be easier if the data was kept together with the issue (I am assuming the custom fields have some space allocated in the jiraissue table, but I could be wrong).  I am looking to track how long each issue spends in each state, open, need more info, pending...  Other suggestions more than welcome.

    1. Mar 31

      Mike Miller says:

      Take a look at Transition Search History Plugin. If it doesn't do exactly what y...

      Take a look at Transition Search History Plugin. If it doesn't do exactly what you want, it at least has source code. Jira Suite Utilities also has a nice tab panel.

  12. Nov 25, 2008

    Michael Kornatzki says:

    Is it possible to configure a custom field like a portlet? I want to make a cus...

    Is it possible to configure a custom field like a portlet?

    I want to make a custom field that shows the text of a field of its parentIssue.
    I see that one way is to use the description of the customField to specify which field should be used.
    I am looking for a way to do the configuration like the navigator-configuration. I want to use a dropdown for all available fields to configure my customfield.

    Kind Regards,

    Michael

  13. Dec 03, 2008

    Michael Kornatzki says:

    Hi, can someone please explain me how the localization for ViewPlugins!defau...

    Hi, can someone please explain me how the localization for ViewPlugins!default.jspa works?

    I want to localize the description for a plugin.

    In src/main/resources/com/ifbag/jira/plugin i have 3 files with the extension .properties (ShowParentField, showParentField_de and ShowParentField_en).
    In the files there is one entry like "showparent.description=This is a lookup field that displays a field of a parent issue"

    In atlassian-plugin.xml i have the following section:<resource type="i18n" name="i18n" location="com.ifbag.jira.plugin.ShowParentField" />
    <customfield-type key="showparentfield" name="Show parent field" class="com.ifbag.jira.plugin.showparentfield.ShowParentField">
      <description key="showparent.description">This is a lookup field that displays a field of a parent issuedescription>
      <resource type="velocity" name="column-view" location="templates/plugins/fields/view/view-basictext.vm"/>
    customfield-type>But this is not enough, the plugin description shows as Text "showparent.description"

    Regards,

    michael

    Solved: put the resource type inside the customfield
    <customfield-type key="showparentfield" name="Show parent field" class="com.ifbag.jira.plugin.showparentfield.ShowParentField">
       <resource type="i18n" name="i18n" location="com.ifbag.jira.plugin.ShowParentField" />
      <description key="showparent.description">This is a lookup field that displays a field of a parent issuedescription>
      <resource type="velocity" name="column-view" location="templates/plugins/fields/view/view-basictext.vm"/>
    </customfield-type>

  14. Feb 13

    Anonymous says:

    there is a little bug in the template edit-jiraadminonlytext.vm: <input type...

    there is a little bug in the template edit-jiraadminonlytext.vm:

    <input type="hidden"
    name="customField.id"
    value="$!value" />
    

    it has to be

    <input type="hidden"
    name="$customField.id"
    value="$!value" />
    
  15. Mar 02

    Anonymous says:

    I believe this is another bug in edit-jiraadminonlytext.vm Please change this: ...

    I believe this is another bug in edit-jiraadminonlytext.vm

    Please change this:

    #if($value && $!value.equals(""))
    

    To this:

    #if($value && ! $value.equals(""))
    
    1. Mar 02

      Nick Menere says:

      Thanks for pointing out, I have fixed both of these bugs. Cheers, Nick Menere J...

      Thanks for pointing out, I have fixed both of these bugs.

      Cheers,
      Nick Menere
      JIRA Developer

  16. Mar 11

    Anonymous says:

    1) I have built the plugin-customfield-sample from examples in jira-development-...

    1) I have built the plugin-customfield-sample from examples in jira-development-kit-3.13 and install in my JIRA instance  Admin page shows the plugin is enabled But I am not seeing the Amazon Search Viewer page any where ? Where can I see that?

    2) I have defined two custom fields to hold and date and integer and trying to define a page which enables user enters bothe these data to be written in internal JIRA database. can some body gives any hints how to do this?

    Thanks

    1. Mar 31

      Mike Miller says:

      1) Did you add a field of type Amazon Search Vieiwer to your project? 2) I dont...

      1) Did you add a field of type Amazon Search Vieiwer to your project?

      2) I dont think you need to create a new custom field to store this, you could simply use the built-in ones.

  17. Mar 30

    Mike Miller says:

    I can't seem to make a searcher work for a CalculatedCFType. atlassian-plugin.x...

    I can't seem to make a searcher work for a CalculatedCFType.

    atlassian-plugin.xml
    <customfield-type key="was-issuetype" name="Formerly Issue Type"
        class="com.mck.mps.erx.jira.field.WasIssueTypeCFType">
        <description>Set to True if the issue was formerly the selected issue type.</description>
    
        <resource type="velocity" name="view"        location="templates/plugins/fields/view/view-basictext.vm"/>
        <resource type="velocity" name="column-view" location="templates/plugins/fields/view/view-basictext.vm"/>
        <resource type="velocity" name="xml"         location="templates/plugins/fields/xml/xml-basictext.vm"/>
    </customfield-type>
    
    <customfield-searcher key="was-issuetype-searcher" name="Was Issuetype Searcher"
        i18n-name-key="admin.customfield.searcher.exacttextsearcher.name"
        class="com.atlassian.jira.issue.customfields.searchers.ExactTextSearcher">
        <description key="admin.customfield.searcher.exacttextsearcher.desc">Search for values exactly matching the input</description>
        <resource type="velocity" name="search" location="templates/plugins/fields/edit-searcher/search-basictext.vm"/>
        <resource type="velocity" name="view" location="templates/plugins/fields/view-searcher/view-searcher-basictext.vm"/>
        <valid-customfield-type package="com.mck.mps.erx.jira" key="was-issuetype"/>
    </customfield-searcher>
    
    

    My WasIssueType simply returns the string "true" or "false" from getValueFromIssue. I am just using text for now to get it working, I can make it prettier later. When I view an issue it returns the string I am looking for, which means it works.

    What is confusing me is that getValueFromIssue only gets called if the issue matches. If I type something into the text box on the find issues page, it never calls getValueFromIssue for any issue. How does it know it doesn't match when it doesn't even test it? I tried TextSearcher with the same result.

    1. Mar 31

      Mike Miller says:

      Hmm, it seems like if you change the searcher config for a field, you must delet...

      Hmm, it seems like if you change the searcher config for a field, you must delete the custom field and re-add it. Since my field is calculated that is no big deal.

  18. Apr 07

    Kunal Sinha says:

    Hi, I am trying to develop a plugin. I wanted to know how the flow goes(u can e...

    Hi,

    I am trying to develop a plugin. I wanted to know how the flow goes(u can explain it taking the example of the above plugin).

    For example which is the first class that gets executed, how does a class refer to the velocity templates ?

    In the below line of code how are we passing or getting the values of actoin customfield id etc :#controlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters.noHeader)

  19. May 05

    Lokesh Dankanachari says:

    Admin-only Field value getting deleted if non-admin users edit any other fields ...

    Admin-only Field value getting deleted if non-admin users edit any other fields

    We did the following
    Inserted following entries into -  atlassian-jira/WEB-INF/classes/system-customfieldtypes-plugin.xml

    <customfield-type key="TestMgrtextfield" name="Test Managers Group Editable Text Field"
    class="com.atlassian.jira.issue.customfields.impl.TextCFType">
    <description>A text field only editable by Test Managers Group. Others will see only text.</description>
    <resource type="velocity" name="view" location="templates/plugins/fields/view/view-basictext.vm"/>
    <resource type="velocity" name="edit" location="templates/plugins/fields/edit/edit-TestMgronlytext.vm"/>
    <resource type="velocity" name="xml" location="templates/plugins/fields/xml/xml-basictext.vm"/>
    </customfield-type>

    Inserted following entries into -  /atlassian-jira/WEB-INF/classes/templates/plugins/fields/edit/edit-TestMgronlytext.vm
    #controlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters.noHeader)

    #if ($authcontext.user.inGroup('Test Manager'))
    <input type="text"
    name="$customField.id"
    value="$!value" />
    #else
    <span title="A text field only editable by Test Managers Group. Others will see only text">$!value</span>
    <input type="hidden"
    name="customField.id"
    value="$!value" />
    #end
    #controlFooter ($action $fieldLayoutItem.fieldDescription $displayParameters.noHeader)

    Any idea what could be wrong ?

    1. May 07

      Rosie Jameson [Atlassian Technical Writer] says:

      Hi Lokesh, Could you please try posting your question in the Developers Forum? ...

      Hi Lokesh,

      Could you please try posting your question in the Developers Forum? http://forums.atlassian.com/forum.jspa?forumID=100

      Many thanks,
      Rosie

Add Comment


Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution 2.5 Australia License.