Update a checkbox on a parent issue based on subtask value

Hi,

I was wondering if anyone can help, using script runner I need to update a checkbox on a parent issue based on a value in a subtask. The script will be executed when the subtask is transitioned into a closed state.

I'm trying to write a custom script.

1 answer

This widget could not be displayed.

I've written the following so far -

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.customfields.manager.OptionsManager;
import com.atlassian.jira.issue.fields.config.FieldConfig;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;



MutableIssue parent = issue.getParentObject();
ComponentManager componentManager = ComponentManager.getInstance();
def customFieldManager = componentManager.getCustomFieldManager();
def optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class)

def cf = customFieldManager.getCustomFieldObjects(parent).find {it.name == "New Environment"}
def fieldConfig = cf.getRelevantConfig(parent);
def uat_value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == 'UAT' }

def changeHolder = new DefaultIssueChangeHolder();
def modVal = new ModifiedValue(parent.getCustomFieldValue(cf),uat_value.toString());

cf.updateValue(null,parent,modVal,changeHolder);

----------------------------------------

I get the following error -


java.lang.ClassCastException: com.atlassian.jira.issue.customfields.option.LazyLoadedOption cannot be cast to java.util.Collection

        at com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType.createValue(AbstractMultiCFType.java:41)

        at com.atlassian.jira.issue.fields.CustomFieldImpl.createValue(CustomFieldImpl.java:854)

        at com.atlassian.jira.issue.fields.CustomFieldImpl.updateValue(CustomFieldImpl.java:522)

        at com.atlassian.jira.issue.fields.CustomFieldImpl.updateValue(CustomFieldImpl.java:504)

        at com.atlassian.jira.issue.fields.OrderableField$updateValue.call(Unknown Source)

        at Script102.run(Script102.groovy:22)



Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

71 views 0 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you