I will preface by saying I have little to no knowledge of scripts... But I am trying to create a script field that will return a text entry based on the text string in another custom field. Here is my code, which returns the "else" case every time:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.component.ComponentAccessor
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
def type = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Risk Type"))
if (type == "New Feature/Function") {
return "Integrated Testing (manual or auto)"
}
if (type == "Logic change") {
return "Ad Hoc Testing (manual or auto)"
}
if (type == "UI change") {
return "Ad Hoc Testing (manual or auto)"
}
if (type == "No functional change") {
return "No testing required"
}
else {
return ""
}
Hey, Sam - a couple questions and things to check out:
I took a stab at some edits to the script - does this work for you?
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.component.ComponentAccessor
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
def type = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Risk Type")).toString()
if (type.equals("New Feature/Function")) {
return "Integrated Testing (manual or auto)"
}
else if (type.equals("Logic change")) {
return "Ad Hoc Testing (manual or auto)"
}
else if (type.equals("UI change")) {
return "Ad Hoc Testing (manual or auto)"
}
else if (type.equals("No functional change")) {
return "No testing required"
}
else {
return ""
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.