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

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

How to set custom field value on new create issue on scriptrunner

Hi Community,

I have this piece of script which is suppose to create a ticket and set value to them.

def issueObject = issueFactory.getIssue()
def cfParticipant = ""
issueObject.setIssueTypeId(project.issueTypes.find { == "Service Request"}.id)

issueObject.setCustomFieldValue(cfParticipant, "addresses")

messageHandlerContext.createIssue(user, issueObject)


But the problem is that it is not setting value for the custom field : ""


Can I get some advice please.


Best regards,

Jason Li

1 answer

1 accepted

1 vote
Answer accepted

Hi Jason,

Do you recall where you found this snippet? The first argument to setCustomFieldValue needs to be a CustomField object rather than a plain string:

def cfParticipant = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Request participants")

The above assumes that you have ComponentAccessor imported; if not, you can do so at the top of your script as follows:

import com.atlassian.jira.component.ComponentAccessor

Note also that ScriptRunner will issue a deprecation warning against the use of getCustomFieldObjectByName. It is safe to ignore this, although for maximum futureproofing you may prefer to replace that call with the following:

getCustomFieldObjectsByName("Request participants")[0]


Joanna Choules, Adaptavist Product Support

Hi Joanna.

Thank you very much for your help. I have been able to sort the problem.


Best regards,


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

104 views 1 7
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