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
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,
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.