It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Create Custom Field using Groovy Script


I am trying to write script (though  for learning curve), but unable to get it through. 

Could someone please help me where am I going wrong??

I am preety sure that arguments i am passing are not correct.

Any help will be greatly appreciated.


import com.atlassian.jira.ComponentManager; 
import com.atlassian.jira.component.ComponentAccessor; 
import com.atlassian.jira.issue.CustomFieldManager; 
import com.atlassian.jira.issue.fields.CustomField; 
import com.atlassian.jira.issue.IssueManager; 
import com.atlassian.jira.issue.Issue; 
import com.atlassian.jira.issue.MutableIssue; 
def issueManager = ComponentAccessor.getIssueManager() 
def customFieldManager = ComponentAccessor.getCustomFieldManager() 
//def cField = customFieldManager.getCustomFieldObject(12905) 
def testcustom =customFieldManager.createCustomField("testcustom", 
//return "Custom field name is" + cField 
return "Customfield created is " + testcustom




1 answer

1 accepted

3 votes
Answer accepted

Hi Aksh,

Try something like the script below (is for a Text Area CF)

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.context.GlobalIssueContext
import com.atlassian.jira.issue.context.JiraContextNode
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.issuetype.IssueType
CustomField createCF() {
    def customFieldManager = ComponentAccessor.getCustomFieldManager()
    def constantsManager = ComponentAccessor.getConstantsManager()
    def taxtAreaType = customFieldManager.
    def textAreaSearcher = customFieldManager.
	//set global context
    List<JiraContextNode> contexts = new ArrayList<JiraContextNode>()

    def bugIssueType = constantsManager.allIssueTypeObjects.find { == "Bug"}
    List<IssueType> issueTypes = new ArrayList<IssueType>()
    return customFieldManager.createCustomField("Text-Area CF",
        "A newly created text area CF for testing",

PS. In order to find JIRA's system custom field type and searcher keys have a look at jira/webapp/WEB-INF/classes/system-customfieldtypes-plugin.xml

@Thanos Batagiannis [Adaptavist] : Thanks for the reply. Though need to change 1 parameter here 

def bugIssueType = constantsManager.getAllIssueTypes().find { == "Bug"}
Like Anzar Khan likes this

I tried this script by creating scripted field, field is created successfully but its scripted field not the text-area field. So can anyone help me, where I have to use this script so that it will create a desired custom field .

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Off-topic

Run into these Solution Partners at Atlassian Open

Hey there Community! Atlassian Open is kicking off in less than a month and we can't wait to touch down in Vienna, Sydney and Boston. This is an opportunity to create the future of teamwork with ...

117 views 0 4
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you