I want to change the default value of component field based on issue type
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
import static com.atlassian.jira.issue.IssueFieldConstants.COMPONENTS
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
import static com.atlassian.jira.issue.IssueFieldConstants.COMPONENTS
if (underlyingIssue) {
return // the issue already exists, therefore this is not the initial action, so don't set
}
def issue_type = getFieldById(ISSUE_TYPE).value
if(issue_type == "Bug" || issue_type == "Enhancement"){
getFieldById(COMPONENTS).setFormValue(["Test"])
} else{
getFieldById(COMPONENTS).setFormValue([])
}
Above code is not working
How do I update default value based on selected issue type?