Hi im trying to assign an issue based on a radio button selected but my code is not working. Radio has two options and based on the option selected a different user should be assigned to the issue when the transition happens. Here is what i have done so far in a script editor. Thanks for any help.
IssueManager im = ComponentAccessor.getIssueManager()
MutableIssue issue = im.getIssueObject("SD-....")
ApplicationUser assignee
UserManager umgr = ComponentAccessor.getUserManager()
final customFieldName = "radioCF"
def customFieldManager = ComponentAccessor.customFieldManager
def dot_cf = customFieldManager.getCustomFieldObjects(issue).find { it.name == customFieldName }
def dot_value = dot_cf.getValue(issue)
if (dot_value == "option1")
{
assignee = umgr.getUserByName('user1')
issue.setAssignee(assignee)
} else if (dotyczy_value == "option2") {
assignee = umgr.getUserByName('user2')
issue.setAssignee(assignee)
}
Hi @Adam G Try below script , add this in Post function . I have tested on my side. It's working.
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
final String userName1 = "user1"
final String userName2 = "user2"
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customfield = customFieldManager.getCustomFieldObject("customfield_27460")
if (issue.getCustomFieldValue(customfield).toString() == "Low") {
def user = ComponentAccessor.userManager.getUserByName(userName1)
issue.setAssignee(user)
}
else if (issue.getCustomFieldValue(customfield).toString() == "Medium"){
def user = ComponentAccessor.userManager.getUserByName(userName2)
issue.setAssignee(user)
}
Kindly change Low and Medium value as per your radio button field values.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much. Works like a charm :). I can move forward because it's not the end of it. Its only the first step of the workflow. Now i need to transition to different status based on the second radio option.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Adam G Great :) Glad to hear it works for you.
For transition, you no need to write script .Use Fast track transition an issue based on Condition. Hope it works for you.
Thanks!
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.