Hi
I am trying to pass the value from a custom field in a sub-task screen to the custom field in its parent Jira. I have done some research and following is what I have.
I am not getting errors when I run the script via ScriptRunner. However, when I added the script to the post function for workflow, the custom field is not updated.
Would you be able to point out what I am missing.. Thank you for any help in advance!!
import org.apache.log4j.Category
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.opensymphony.workflow.InvalidInputException
MutableIssue mutableIssue = issue;
MutableIssue parentIssue = mutableIssue.getParentObject();
ComponentManager componentManager = ComponentManager.getInstance();
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager();
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
String customFieldName = "customfield_11112";
CustomField cf = customFieldManager.getCustomFieldObject(customFieldName);
String parentCustomFieldValue = parentIssue.getCustomFieldValue(cf).toString();
String subTaskCustomFieldValue = mutableIssue.getCustomFieldValue(cf).toString();
//cf.updateValue(null, parentIssue, new ModifiedValue(parentIssue.getCustomFieldValue(cf), mutableIssue.getCustomFieldValue(cf)), changeHolder);
cf.updateValue(null, parentIssue, new ModifiedValue(parentIssue.getCustomFieldValue(cf), "test"), changeHolder);
//IssueIndexManager issueIndexManager = ManagerFactory.getIndexManager();
//issueIndexManager.reIndex(issue);