We have a requirement for the Assignee field to have an Assignee in all statuses and all issue types except for the initial status. To avoid having to add a Field Required (JSU) Validator to each and every transition (which would still allow blanking out the Assignee when the issue is static), we implemented a Behaviour:
// Make Assignee field required
import static com.atlassian.jira.issue.IssueFieldConstants.*
// Field is not required during Create
if (getActionName() != "Create"){
// Field is not required in an initial status
if (!(underlyingIssue.getStatus().getName() in ["Backlog","Triage"])){
getFieldById(ASSIGNEE).setRequired(true)
}
}
However, even though the field now appears Required, and it does not accept selecting Unassigned, it still allows being blanked out, which results in the issue being Unassigned.
It appears a blank field corresponds to "Automatic", which the Behaviour accepts as a non-blank value, and "Automatic" results in a value of "Unassigned" in our projects.
Is there any way to get this to work properly?
I have had success with this. Can you try it out and let me know how it goes?
import static com.atlassian.jira.issue.IssueFieldConstants.*
// Field is not required during Create
if (getActionName() != "Create"){
// Field is not required in an initial status
if (!(underlyingIssue.getStatus().getName() in ["Backlog","Triage"])){
def assignee = getFieldById("assignee")
def user = assignee.getValue()
assignee.setRequired(true)
if((user as String == '-1') || !user){
assignee.setError("You must add an assignee.")
}
else { assignee.clearError() }
}
}
Hi @Jozef Vandenmooter and @Kirkie
Could you give me a step-by-step guide on implementing this Behavior?
I'm struggling to get this script working. I think I'm missing some libraries.
you help will be highly appreciated in this regard,
Thanks
Lwandile
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
these are the errors I'm getting:
[Static type checking] - Cannot find matching method Script614#getActionName(). Please check if the declared type is correct and if the method exists.
[Static type checking] - The variable [underlyingIssue] is undeclared.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Lwandile Rorwana ,
Below is the code that works fine for me.
// Make Assignee field required
def issueStatus = underlyingIssue?.getStatus()?.getName()
def issueType = underlyingIssue?.getIssueType()?.getName()
def assignee = getFieldById("assignee")
def user = assignee.getValue()
// Field is not required during Create
if (getActionName() != "Create") {
// Field is not required in initial and end statuses (To Do is not an initial status of the Story and Task)
// if (!(issueStatus in ["Open", "Backlog","Triage","To Do","Closed","Done"]) || (issueStatus == "To Do" && issueType in ["Story","Task"])) {
// This is not in Prod:
if (!(issueStatus in ["Backlog","Triage","To Do","Open","Closed","Done"]) || (issueStatus == "To Do" && issueType in ["Story","Task"]) || getActionName() == "In Progress") {
assignee.setRequired(true)
if ((user as String == '-1') || !user) {
assignee.setError("You must select an Assignee.")
}
else {
assignee.clearError()
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jozef Vandenmooter ,
Thank you for your prompt feedback.
could you please walk me through on how you implemented this behavior?
It's still not working when I tried it on the script console here are the errors I'm getting.
this is how I configured the behavior
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't understand why you're getting those errors... Below screenshots of how I have it set up.
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.
Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!
Join an Atlassian Community Event!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.