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

JIRA Multi select checkbox customfield not getting updated properly Edited

Komail Badami May 12, 2017

I have a transition screen from which I am getting values(s) via a checkbox control,  I need to get these values and update them on another checkbox control in the issues view screen. I tried the below code and it worked but it doesnt set the checkbox option as selected but just shows the value like a editable text but when I clicked edit that option is not selected. 

def changeHolder = new DefaultIssueChangeHolder()
custField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(custField), platvalue),changeHolder)

I read that you need to use options , so I used the below code but it doesnt work

def optionsManager = ComponentAccessor.getOptionsManager()

def config = platRelOnAPIField.getRelevantConfig(issue)

def options = optionsManager.getOptions(config)

log.debug("Options of Plat rel on field in API:"+options) // This prints properly

def newOption  = options.get(7) //I want to set to the 8th checkbox just for example,this value prints properly

ModifiedValue mVal = new ModifiedValue(issue.getCustomFieldValue(platRelOnAPIField),newOption);

platRelOnAPIField.updateValue(null, issue, mVal, new DefaultIssueChangeHolder());

But I end up with this exception


java.lang.ClassCastException: com.atlassian.jira.issue.customfields.option.LazyLoadedOption cannot be cast to java.util.Collection

I am a newbie to groovy/jira apis , so please can someone help me to set the checkbox value properly for the customfield

Ive checked this

but I still get the same exception :( 


Thanks !

2 answers

2 votes
Nic Brough [Adaptavist] Community Leader May 12, 2017

A checkbox is an array of options - consider the list:

  • Red X
  • Greeen
  • Orange X
  • Blue X

There, it's got three options selected, so the value of the field is actually a collection of three.  You need to place the option you want into a collection of options to pass into the field, even if you only have one option to select.

Komail Badami May 12, 2017

Ok. Now I have a collection of options called platvalue which holds the values I want to update  and this statement works

custField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(custField), platvalue),changeHolder)

but it doesnt check the checkboxes for those values for my custField(one to be updated), here 

platvalue = issue.getCustomFieldValue(platRelOnField) //platRelOnField is the field from where I am getting my values to be set



Nic Brough [Adaptavist] Community Leader May 12, 2017

That's a step forward, the next question is about what you see in the logs when this stuff runs.  If it's not updating anything, I'd expect an error message that at least hints at the problem.

Komail Badami May 13, 2017 • edited

I checked for any error in the logs, there are no errors as such :( Don't know where I am going wrong. The values are shown against the field but the checkboxes remain unchecked.

However, I find this line

[webpanels.children.condition.ChildIssuesPanelVisibilityCondition]Exception when evaluating if child issues panel should be displayed

But I dont think it has anything to do with my code


Nic Brough [Adaptavist] Community Leader May 14, 2017

Ok, you'll have to go into quite a bit of debugging now.  I'm not sure what's wrong (unless the code you've not shown us here is somehow blanking out the field data you're trying to put into the change), but I'd check the values of variables on each line until you find out where the nulls/empty data is coming from.

0 votes
Komail Badami May 15, 2017 • edited

I managed to get this working with the below code

ArrayList<LazyLoadedOption> optionsList = new ArrayList<LazyLoadedOption>();

FieldConfig fieldConfig = platRelOnAPIField.getRelevantConfig(issue);
OptionsManager optionManager = ComponentAccessor.getOptionsManager();
platOptions = optionManager.getOptions(fieldConfig);

for(def i = 0;i<platOptions.size();i++){
    def optVal = platOptions.get(i).getValue();
    if(platOptions.get(i).getValue().equals("custom field value")){

Now I have optionsList which I pass like before to updateValue

platRelOnAPIField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(platRelOnAPIField), optionsList),changeHolder)


Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Jira

Try Jira Cloud for Outlook: Organize your work without leaving your inbox

Hi Atlassian community, My name is Max and I work on the product integration team at Atlassian. I am pleased to announce the early access program for the Jira Cloud add-in for Outlook. This add-in...

1,716 views 3 15
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