So I have been reading Q&A in the community for days now in the hopes that I'd be able to muddle through this 'simple' post-function script. I have finally decided that I need to ask the community for help.
Here's what I'm trying to accomplish:
I have a parent task with multiple sub-tasks. In the sub-task workflow, I would like a custom script post-function which evaluates the issue type name, and based on that name, then assigns the current date to a specific custom field in the parent issue. Also, based on the issue type name, the status the sub-task is transitioning to is assigned to a specific custom field in the parent issue.
I was thinking this would be a good application for using 'switch'. Below is what I have so far, and I'm sure it's way off base. Any help would be appreciated. I've commented-out some of the lines as I've tried working through this.
Thanks!
import com.atlassian.jira.ComponentManager
//import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
//import com.atlassian.jira.issue.getIssueType
import com.atlassian.jira.issue.issuetype.IssueType
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.index.IssueIndexManager
import com.atlassian.jira.util.ImportUtils
import java.sql.Date
import java.sql.Timestamp;
//MutableIssue issue = new MutableIssue()
MutableIssue mutableIssue = issue;
MutableIssue parentIssue = mutableissue.getParentObject()
//Issue parentIssue=issue.getParentObject();
switch (issue.issueType.name) {
case "Name X":
parentissue.setCustomFieldValue(PCF1,issue.getStatus);
parentissue.setCustomFieldValue(PCF2,Timestamp);
break;
case "Name Y":
parentissue.setCustomFieldValue(PCF3,issue.getStatus);
parentissue.setCustomFieldValue(PCF4,Timestamp);
break;
}
indexManager.reIndex(parentIssue);