Hi @Chaya
Not sure if it's the only issue but you do a comparaison between an issue type object and a string. You should use
getFieldById(ISSUE_TYPE).value?.name
It may display an error because you did not declare it as IssueType but it should work.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your code seems to be valid except that getFieldById(ISSUE_TYPE).value return the issue type id not the issuetype name
so def issue_type = getFieldById(ISSUE_TYPE).value.toString()
Then
if(issue_type == "XXXX" || issue_type == "YYYY"){
WHere XXXX and YYYY are issue type ids, not name
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can try ussing issueContext instead "getIssueContext().issueType.name"
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPEimport static com.atlassian.jira.issue.IssueFieldConstants.COMPONENTSimport static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPEimport static com.atlassian.jira.issue.IssueFieldConstants.COMPONENTSif (underlyingIssue) {return // the issue already exists, therefore this is not the initial action, so don't set}def issue_type = getIssueContext().issueType.nameif(issue_type == "Bug" || issue_type == "Enhancement"){getFieldById(COMPONENTS).setFormValue(["Test"])} else{getFieldById(COMPONENTS).setFormValue([])}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.