Hi Community,
Can you advice me on what's wrong with my code? it seems not to work when I want to change the value of Issue Type (e.g. Bug to Problem) using the value of single select field.
Here's my code:
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def regressionIssueField = getFieldById(getFieldChanged())
def regressedVersionField = getFieldByName("Issue Type")
String regressionIssueValue = regressionIssueField.getValue()
if (regressionIssueValue == "Sample") {
regressedVersionField.setFormValue("Service Request")
} else {
regressedVersionField.setFormValue("Service Request with Approvals")
}
Hello @Alvin
Please see the sample here
https://scriptrunner.adaptavist.com/latest/jira/recipes/behaviours/restricting-issue-types.html
Instead of using
regressedVersionField.setFormValue("Service Request")
You can use (as the example in the link) i.e. use setFieldOptions (with value of the issueTYpes which you want to set)
issueTypeField.setFieldOptions(availableIssueTypes)
Please see this sample as well
You can change the issueType value to Problem and then lock the value by making the field Read-only.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tarun Sapra, I just forgot to import this :
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
now it works fine. Thank you so much
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.