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: https://developer.atlassian.com/display/JIRADEV/JIRA+Plugin+Guide. However Jelly script can of course also add a field to a screen: https://confluence.atlassian.com/display/JIRA/Jelly+Tags#JellyTags-jira:AddFieldToScreen 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 vote

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 $customField.id $customField.name $fieldLayoutItem.required $displayParameters.noHeader) <input type="textarea" name="$customField.id" value="$!value" /> #set ($displayValue = ${value}) #controlFooter ($action $fieldLayoutItem.fieldDescription $displayParameters.noHeader) My java Class File : JiraCustomField.java 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 vote

Have you added the custom field to the screen?

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,331 views 14 20
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot