Remove Due Date when the item is checked
This example shows how you can modify the existing checklist value. You can use this example to implement your desired use case. In this case, we are removing the due date as soon as an item is checked.
Steps
Create a new ScriptRunner Behaviour and select the desired project and issue type mappings.
In the Add field section, add the Checklist field.
Select Create script to add a script when your Checklist field changes.
In the script, use the following snippets:
Retrieve the existing value of the checklist:
GROOVYdef checklistFieldName = "DoD"; def checklist = getFieldByName(checklistFieldName); String value = checklist.getFormValue(); Collection<ChecklistItem> items = ChecklistSerializer.deserializeChecklist(value);
Remove the due date of any item that is checked:
GROOVYitems.forEach { item -> if (item.isChecked()) { item.setDueDate(null); } }
Update the value in the checklist field.
GROOVYString newValue = ChecklistSerializer.serializeChecklist(items); checklist.setFormValue(newValue);
Full Example
import com.onresolve.scriptrunner.runner.customisers.WithPlugin;
@WithPlugin("com.okapya.jira.checklist")
import com.okapya.jira.customfields.*;
def checklistFieldName = "DoD";
def checklist = getFieldByName(checklistFieldName);
String value = checklist.getFormValue();
Collection<ChecklistItem> items = ChecklistSerializer.deserializeChecklist(value);
items.forEach { item ->
if (item.isChecked()) {
item.setDueDate(null);
}
}
String newValue = ChecklistSerializer.serializeChecklist(items);
checklist.setFormValue(newValue);