I have a custom field (checklist) which contains number of todo items , Initially in unchecked state. When some conditions occur I want to change the state of a single item ( to checked ) using Groovy.
eg. say i have "item 1", "item 2", "item 3" in checklist. I want to update status of "item 2" to checked using groovy.
So far I have done the following
final CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
def cf = customFieldManager.getCustomFieldObject("customfield_10009");
def cfType = cf.getCustomFieldType()
List item = new ArrayList();
item.add(cfType.getSingularObjectFromString('{"name" : "Item 1", "checked" : true, "mandatory" : false ,"option":true}'))
def changeHolder = new DefaultIssueChangeHolder()
cf.updateValue(null, parentIssue, new ModifiedValue(issue.getCustomFieldValue(cf), item),changeHolder)
The output of above code is that the item to update status ("item 2") is appended to the checklist with status checked
Before running:
after running :