Forums

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

Check the Checklist using groovy script

jayakrishnan nampoothiri c.n April 25, 2018

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: Capture2.PNG

after running : Capture.PNG

 

0 answers

Suggest an answer

Log in or Sign up to answer