For one issue type (Bug), I would like to set the default value of the Assignee Field to a user called "Unconfirmed". By this I mean that users can still edit the assignee field on the Create Screen, but the field default shows as Unconfirmed.
(I'm not interested in automatic assignment using Post Functions in this scenario)
For all other issue types, I would like to set the default value of the Assignee Field to "Automatic"
I'm attempting to accomplish this using ScriptRunner Behaviors, but can't get it to work properly. The code below is what I have currently. I have tried this as both an initialiser function as well as a serverside script for the Assignee field.
Any assistance is appreciated!
import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.*
if (getActionName() != "Create Issue") {
return
}
//Value of 1 = Bug Issue Type
if (getFieldById(ISSUE_TYPE).getFormValue() == 1)
{
getFieldById(ASSIGNEE).setFormValue("Unconfirmed")
}
else
{
getFieldById(ASSIGNEE).setFormValue("Automatic")
}
Hi Jordan,
You can't just set a random value like "Unconfirmed" or "Automatic" to the 'Assignee' field. Thing is, the 'Assignee' field is effectively a list of user objects, so you have to either select a user object as its value or set it to 'null' (which is displayed as "Unassigned").
That said may I suggest a slightly different approach to your issue? It is my understanding that you have a default assignee configured for all issue types within your project. With that in mind I'd like to suggest that you simply use a scripted post-function to change the assignee to 'Unassigned' when an issue is created if that issue happens to be a 'Bug' type?
To do that created a scripted post-function on your 'Create' transition using the code below. Also make sure that this post-function is placed right AFTER "re-index issue....." post-function.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.UpdateIssueRequest
if (issue.getIssueType().getName() == "Bug"){
/*choose the user who will be the used as issue updater*/
def updater = ComponentAccessor.getUserManager().getUserByName("username")
issue.setAssignee(null)
ComponentAccessor.getIssueManager().updateIssue(updater, issue, UpdateIssueRequest.builder().build())
}
Hi Ivan,
I appreciate the help, but as stated, I'm not interested in solving this problem through Post Functions. Particularly, in the Create Screen, I'd like to set a Default Assignee option, but still allow users to make a choice, rather than auto-assign after the transition.
I've been able to get the basics of this working (change default for Bugs) by using Initializer Functions in the Behaviors section of ScriptRunner. However, I can't figure out how to have the Default set for Bugs, then switch back to Automatic for all other Issue Types as the initializer only fires once.
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.