How do I add a custom label type field to JIRA's issue create/edit/view screens?

I have a field called Execution Status, it is a label field with three options, Pass Fail and Error. I cannot figure out how to add the field to JIRA's issue pages programmatically. I followed the tutorial and found out how to add a custom field which can be added by the JIRA admin, but I want to put a new field on existing issue pages automatically when my plugin is downloaded.

Here is my xml (view edit are same template because nothing is appearing on screen and I just wanted to test it):

<customfield-type key="Execution-Status-field" name="Execution Status" class="com.seguira.jira.plugin.ta.action.ExecutionStatusField"><description>Seguira Test Execution Field</description> 
<resource type="velocity" name="view" location="templates/actions/view-basictext.vm"/>
<resource type="velocity" name="edit" location="templates/actions/view-basictext.vm"/>
<resource type="velocity" name="xml" location="templates/actions/xml-basictext.vm"/>
</customfield-type>

ExecutionStatus.java:

public class ExecutionStatusField extends LabelsCFType { 

public ExecutionStatusField(JiraAuthenticationContext jac, IssueManager im, GenericConfigManager gcm, LabelUtil lu, LabelManager lm, ProjectImportLabelFieldParser pilfp, JiraBaseUrls jbu) {
super(jac, im, gcm, lu, lm, pilfp, jbu);
}

}

 

I found this code online, and added some to it:

FieldScreenManager fieldScreenManager = ComponentAccessor.getFieldScreenManager();

FieldScreen screen = fieldScreenManager.getFieldScreen(new Long(10001));
FieldScreenTab defaultTab = screen.getTab(0);
defaultTab.addFieldScreenLayoutItem(customFieldId);

I'm unsure where to get the custom field's ID

and the vm file:

<select 
class="multi-select long-field hidden edit-labels-inline multi-select-select" 
name="$customField.id" value="Pass" id="$customField.id"
multiple="multiple" >
</select>

Thanks in advance!

 

1 answer

This widget could not be displayed.
Thomas Schlegel Community Champion Apr 20, 2017

Hi Shashank,

there's another community for developer's issues:

https://community.developer.atlassian.com/

Maybe you get an answer there sooner.

I've posted on there, but can't seem to delete this issue. Anyway, here is the link to the dev community post: https://community.developer.atlassian.com/t/how-do-i-add-a-custom-label-type-field-to-jiras-issue-create-edit-view-screens/2807

Thomas Schlegel Community Champion Apr 20, 2017

No problem, here are also a lot of developers reading and answering the questions.

 

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

115 views 2 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you