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

Looking for a script to fill customfield (multiple-checkboxes) in over 300 issues

Hello friends,

I must perform a action in over 300 issues to fill a customfield. I has write a user define servlet as plugin, to do it.

In over 300 issues I look for some other fields and keywords in description and write a arraylist with the values of my checkboxes. Now my problem is to assign the it to customfield of issue.

MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject("TEST-1")

ArrayList<String> opt=new ArrayList<String>();

CustomField f = ComponentAccessor.getCustomFieldManager.getFieldByName("mycheckboxfield")

Why my last-line in code-Snipped doesn't assign the value to the issue?
(None exception or log-warnings was written.)

Know anyone a better way to reach this goal?

Thank you in advance for your spend time.

Best regards

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted


I think you have to use an com.atlassian.jira.issue.customfields.option.Option object from the existing options of the multi-checkbox custom field fieldconfiguration as argument for setCustomFieldvalue().

If you want to use Strings as value you could use the IssueService.update() (

For tasks like this I use the ScriptRunner Plugin, but maybe, the way Renjith suggested, using CLI, could be preferred.


Can you wirte a smal example-code, please?

If the sample is for CLI, you need to just read

jira --action updateIssue --issue "ZJIRACLI-4" --field "custom1" --values "xxxx"

Sorry ;)

IssueService issueService = ComponentAccessor.getIssueService();
IssueInputParameters issueInputParameters = new IssueInputParametersImpl();
issueInputParameters.addCustomFieldValue(cFO.getId(), "10017" );
UpdateValidationResult updateValidationResult = issueService.validateUpdate(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue.getId(), issueInputParameters);
issueService.update(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), updateValidationResult);

Is that correct so?

Whats the seperator for assign more than one optionfield-values?

String[] val=new String[2]; val[0]="10017"; val[1]="10018";
issueInputParameters.addCustomFieldValue(cFO.getId(), val );

work fine!

Try something like this within ScriptRunner:

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.issue.IssueInputParametersImpl

Issue issue
IssueService.UpdateValidationResult validationResult
IssueService.IssueResult updateResult

ComponentManager cm = ComponentManager.instance
IssueService issueService = cm.issueService
Long customFieldId = 10000 // Id of your customfield
String[] myValues = ["15345","12345"]  // String array of valid option Ids for your customfield
User myUser  = cm.jiraAuthenticationContext.getLoggedInUser()
IssueInputParameters issueInputParameters

// Find your issues here and use the following code on each of them

issueInputParameters = new IssueInputParametersImpl([:])
issueInputParameters.addCustomFieldValue(customFieldId, myValues)

validationResult = issueService.validateUpdate(myUser,, issueInputParameters)

if (validationResult.isValid()) {
    updateResult = issueService.update(myUser, validationResult)
    if (!updateResult.isValid()) {
        updateResult.errorCollection.errors.each {log?.error "Error: $it"}
} else {
    validationResult.errorCollection.errors.each {log?.error "Error: $it"}

Be aware that the value array will override the current selected checkboxes for the issue.


Oh... you already got it :-)

Thats working fine, with some parameters...

But only I must switch off mail-sending durring this batch-opperation.

How can I switch off mails for only the affected issues and this shortly time?

To supress notifications you can surround the issueService code with

import com.atlassian.jira.util.ImportUtils

boolean wasNotify = ImportUtils.isEnableNotifications()
try {

	// update Issue ..
finally {
	ImportUtils.setEnableNotifications(wasNotify)                   // Reset notification state

This disables notifications for the whole system, but maybe for this short time period this is ok for you.


Or you could try adding

validationResult.getAdditionInputs().put("sendBulkNotification", false)

after the validation, but I didn't tried this by myself. Maybe you could report here if this works :-)

That method is only on TransitionValidationResult...

0 votes
Timothy Chin Community Leader Jan 08, 2013

Have you tried to use the id of the option?

no, thats a diea... I test it today in afternoon.

no success...

MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject("TEST-1")
ArrayList<Long> opt=new ArrayList<Long>();
opt.add(10017L); // ID from the CUSTOMFIELDOPTION-Table
CustomField f = ComponentAccessor.getCustomFieldManager.getFieldByName("mycheckboxfield")

doesn't work


OptionsManager opM = ComponentAccessor.getComponentOfType(OptionsManager.class);

MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject("TEST-1")

ArrayList<Option> opt=new ArrayList<Option>();
CustomField f = ComponentAccessor.getCustomFieldManager.getFieldByName("mycheckboxfield")

doesn't work

Has anyone more ideas?

I has found flowing text in java-doc:

void com.atlassian.jira.issue.MutableIssue.setCustomFieldValue(CustomField customField, Object value)

Sets a custom field value on this Issue Object, but does not write it to the database. This is highly misleading.
To actually set a custom field value, use CustomField.updateIssue(com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem, MutableIssue, java.util.Map)

<dl><dt>Parameters:</dt><dd>customField the CustomField</dd><dd>value the value.</dd></dl>

The value is correctly assign the issue-object (last code-snippet), when I hover in eclipse-debug, but it was not store in database!

How I get the content for variable com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem ??

Why do you want to write a plugin? Just use JIRA CLI and get them updated using a script.

I donn't have any practical experience with JIRA-CLI.

Can you write a example? I must check before some constulations in description-text and other field before I can fill my custom-value with the dynamic data's. Additional the script must be execute by an external application... So I need a call over HTTP/HTTPs (for example Servlet or Webservices).

I thik thats to comlex for JIRA-CLI... Or wath is you opinion?

CLI is the easiest, for doing some thing for one time, no one usually writes a plugin.

If you want to really write some java code, then you can use the Script Runner Plugin and then use the script console.

When I wirte java in ScriptRunnerPlugin, I has the same problem that I wrote in topic. Whats the different when I use Eclipse (with code-assistent, svn, ...) and write a plugin or I write java with plain-text-editor in ScriptRunnerPluin?

I need in both a solution to assign my value to the custom-checkbox-field.

Well, that was just my preference, as I would just download CLI, check the examples in Bob's page, run a 'for' loop in my shell to update all the issues (probaly I will also 'getIssueList' using CLI first to get a list of issues).

Check out writing the plugin, it may be easier for you.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

Community showcase
Published in Atlassian Community Events

It is me, Andy B ! a.k.a. FUN MAN ANDY [Community Showcase]

COMMUNITY SHOWCASE – FUN MAN ANDY “Showcases spotlight Atlassian Leaders who make a big impact on our Community. The Atlassian Community Team taps Leaders to share more about themselves and their A...

157 views 10 9
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