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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

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 anzark7 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 .

Community showcase
Posted in Featured Groups

Mythbusters: I'm too new to contribute to Community

Editor’s note: The Welcome Center is a great place to learn how best to navigate the Atlassian Community. “My question is SO basic. I don’t feel comfortable asking it here.” “I don’t have nearl...

261 views 10 17
View post

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