Can any one help me how to Add a custom field programmatically

I want to add a customField(readonly textbox) programmatically

can it is possible in JIRA 


4 answers

Thanks Nic Brough & Udo Brand can you please share the some links or any document to write the custom plugin for jira 1- automatically create the custom field and Associate the field to the appropriate screens

For a plugin development you might start here: However Jelly script can of course also add a field to a screen: Since I have not developed a plugin by myself I'm not sure if it's worth the time unless you want to add custom fields frequently.

I'd seriously reconsider the design here - is it *really* worth going through the process of researching and writing code for a plugin to add a couple of custom fields that you could just document for the end-user? If your argument is "but I need lots of custom fields", then I'd say that's a bad requirement - having lots of custom fields is a bad idea on many levels, and you probably need to re-evaluate it. (There is only one strong argument for "create custom field in a plugin" that I can think of, but I suspect it's not one you actually have)

0 votes

Depends on what you mean.  

You have phrased the question in a slightly ambiguous way (the wonders of the English language - even simple sentences can be immensely unclear).  

It sounds like you want to add a new custom field.  But a lot of people who ask that actually mean "How do I add data to a custom field", and that's a very different answer.

If you do really mean add a new custom field, then yes, of course you can, but you can only do it in a plugin that has direct access to the internals, or, as Udo has said, with a Jelly script.  You also need admin rights for the process you're running.  It's also not something you need to do often enough to justify coding it - almost every addon I know of that needs you to add custom fields simply puts "add custom field X" in the "How to install and use me" documentation.

If you do mean "set the data", then you've got a lot more options - Jelly and code in a plugin are still valid approaches, but you can also use REST, web hooks, external programs, tricks in the UI and and and...

Thanks Udo Brand & Nic Brough I am able to create as well Add custom field automatically using custom plugin code : Add in the atlassian-plugin.xml: <!-- import from the product container --> <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties"/> <!-- Add custom field by java code --> <customfield-type key="admintextfield" name="Admin Editable Text Field" class="com.atlassian.jira.plugin.customfield.example.JiraCustomField"> <resource type="velocity" name="edit" location="templates/edit-jiraadminonlytext.vm"/> <description>Text field </description> </customfield-type> My edit-jiraadminonlytext.vm #controlHeader ($action $ $ $fieldLayoutItem.required $displayParameters.noHeader) <input type="textarea" name="$" value="$!value" /> #set ($displayValue = ${value}) #controlFooter ($action $fieldLayoutItem.fieldDescription $displayParameters.noHeader) My java Class File : customFieldList = ComponentAccessor.getCustomFieldManager().createCustomField("MycustomField", "customField", field.getCustomFieldType(), field.getCustomFieldSearcher() ,null, field.getAssociatedIssueTypes()); Problem statement: Above code create a custom field (name = "MycustomField"). I am set the value of MycustomField at the time of issue creation but value of MycustomField is not shown in the bug screen Thanks in Advance

0 votes

Have you added the custom field to the screen?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,230 views 5 10
Read article

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