Creating: "Custom script post-function"
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.security.groups.GroupManager;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
GroupManager groupManager = ComponentManager.getComponentInstanceOfType(GroupManager.class)
if (cfValues['selectBoxCustomField']?.value == 'Value1') {
issue.setSecurityL
} else if (cfValues['selectBoxCustomField']?.value == 'Value2') {
issue.setSecurityLevelId(10105)
} else if (cfValues['selectBoxCustomField']?.value == 'Value3') {
issue.setSecurityLevelId(10104)
} else if (cfValues['selectBoxCustomField']?.value == 'Value4')) {
issue.setSecurityLevelId(10103)
}
cfValues['selectBoxCustomField']?.value == 'Value1' fires exception. How can I retrieve "selectBoxCustomField" value?
import com.atlassian.jira.component.ComponentAccessor def customFieldManager = ComponentAccessor.getCustomFieldManager() def cf = customFieldManager.getCustomFieldObjectByName("Name of select box field") def optString = issue.getCustomFieldValue(cf)?.value if (optString == "Value") { ... } else if (...) { .... }
Thank you!
I've just found solution myself, but yours is shorter:
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
MutableIssue issue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def textFieldCf = customFieldManager.getCustomFieldObjectByName("GRS area")
def cfvalue = issue.getCustomFieldValue(textFieldCf)
String value = cfvalue.toString()
if (value == 'value1') {
issue.setSecurityLevelId((long)10715)
} else if (value == 'value2') {
issue.setSecurityLevelId((long)10705)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
that will fail when there is no option set... so mine uses ?
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.