Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Modify default options in the checklist

Jan Scherks February 28, 2020

Hi,

I'm trying to create a Scriptrunner listener to get one checklist custom field, verify states of each default options (checked/unchecked) and based on other 2 custom fields (single select list) check one of the options.

So far I'm able to get the current state of the default options but I'm struggling to modify them.

Using

getSingularObjectFromString()

I can only use

name, checked and mandatory

inside. But adding only those 3 will not actually update existing options but create completely new options which I don't want.

If I try to add all the parameters the execution fails with following error

Script console script failed: com.atlassian.jira.issue.customfields.impl.FieldValidationException: Invalid String. Could not convert into Checklist Item

Any suggestions would be great. 

Thanks

Jan

1 answer

0 votes
Maxime Lefebvre _Okapya_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2020

Hi Jan,

Options needs the "optionId" property to be properly found, but without a code snippet I cannot know if this is the right approach.

Here is an example of what you could do:

CustomField cfield = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("My Checklist Field");
def items = issue.getCustomFieldValue(cfield);
for (def item : items) {
if (item.getOptionId() == 1234) {
item
.setChecked(true);
}
}
issue.setCustomFieldValue(cfield, items);

Regards,

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events