Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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
Published in Opsgenie

Opsgenie and Amazon team up to launch new DevOps Guru integration - now available!

We’re proud to announce that our integration with Amazon DevOps Guru is now live. The Amazon and Opsgenie product teams have worked together to build a deep integration between Opsgenie and the new...

280 views 0 12
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