Workflow validator: Make field mandatory based on security level

PFS August 24, 2016

Hi

We have two security levels which requires the user to set an assignee and unassigned is not allowed. I then tried to add the following script into a validator in the "Create" transition.

if(issue.getSecurityLevelId() == 10305 || issue.getSecurityLevelId() == 10308)
{
    issue.assignee != null
}

However, now the create dialogue wants an assignee for every security level. It seems like it ignores my if-check.

Can somebody help me on this?

Thanks and best regards

Marius

1 answer

1 accepted

1 vote
Answer accepted
PFS August 25, 2016

Solved it with this condition:

((issue.getSecurityLevelId() == 10305 || issue.getSecurityLevelId() == 10308) && issue.assignee != null) || (issue.getSecurityLevelId() != 10305 && issue.getSecurityLevelId() != 10308)

However, can't I use if-checks the way I did in my first post?

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 30, 2016

try using

if (issue.getSecurityLevelId() == 10305L || issue.getSecurityLevelId() == 10308L) {
    return issue.assignee != null
}
return true
Deleted user August 30, 2016

Oh, I see smile Thanks that works as well. I guess the letter L after the security level ID is a mistype? I removed it and it worked either way.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 30, 2016
Deleted user August 30, 2016

Oh, okay. Didn't know that but I'll keep this in mind. thanks again

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events