Part 2: Using jQuery and Custom fields to rename the Fix Version/s field in Jira


Following up on my previous article on this topic I would like to show how using similar techniques you can rename the Fix Version/s field (analogue for the Afffected Version/s field) when creating, editing or viewing an issue. I’ve seen requests on the Jira Issue site for this, mostly because there are teams that are using Agile/scrum development and they want to rename the Version to Milestone, Sprint or just something else. Jira currently does not support this out-of-the-box unless you are willing to dive into the localization jars and change those yourself, which kind of a bummer since they do support agile development through the – in my opinion overpriced - Greenhopper plugin.

Okay this is how the issue creation screen looks like without our little gimmick:

I blacked out some values just for privacy reasons, but you get the point. Now if all you need is to change the text Fix Version/s to in our case Milestone all it takes is the following script:


<script language="JavaScript">

jQuery(function(){
	AJS.$("label[for=fixVersions]").replaceWith(" <label for='fixVersions'><span class='required' title='Fields in italics are required'><sup>*</sup>Milestone:</span></label>");
});

</script>

As you can see I’m using jQuery to look for a label element where the for attribute is set to ‘fixVersions‘ and replace it with a new label element.
That’s all! Well not all, you still need to get it on your pages. To do this I’ve used a Message Custom Field (for edit). If you also want this on your viewing page you need to create a second custom field of type Message Custom Field (for view) and set the default value of both custom fields to the script. To apply this text replacment to all screens, issue types and projects (create,edit and viewing) it’s best to set the context to ‘Global‘ and ‘Any issue type‘. and you are good to go. When applied the screen screen will look like this:

The Message Custom Field can be found in the Jira Toolkit plugin

Of course this technique can be applied to whatever field if you like, just remember it is a text replacement on rendering of the page so in the system nothing changes! If there is an error message about the Fix Version/s field for example when it is required and no version is selected the error message will not be using the term ‘Milestone‘.

, , , , ,