Syntax for multiple conditions and additional actions in script "Clones an issue and links"

I finally got the priority to update correctly in the cloned issues but now I am having trouble with the conditional parameters. I need the post function to evaluate the "Severity" field as Level 1, 2 or 3 and set the appropriate "Priority" in the cloned issue.

What happens is that no matter what the Severity is set to, 3 clones are created. How can I setup the post function to evaluate multiple conditions and do something based on the condition that matches?

I currently have 3 post functions setup. Can I combine these into one post function?

condition 1

issue.resolution?.name == 'Entered into Product Backlog'

cfValues['Severity'] = "Level 1/Critical"

action 1

issue.priorityId = '1'

condition 2

issue.resolution?.name == 'Entered into Product Backlog'

cfValues['Severity'] = "Level 2/Severe"

action 2

issue.priorityId = '3'

condition 3

issue.resolution?.name == 'Entered into Product Backlog'

cfValues['Severity'] = "Level 3/Important"

action 3

issue.priorityId = '4'

2 answers

1 accepted

Thanks Jamie! I just had to make one small change to get it to work.

issue.resolution?.name == "Entered Into Product Backlog" && cfValues['Severity'].value == "Level 1/Critical"

0 votes

You're still confusing = and ==. All your conditions are evaluating to true.

In your conditions you probably want == , ie test for equality.

In the action field you probably want =, ie assignment.

In the condition unless you are && or || ing the statements together all except the last one will be ignored. So it's really not clear to me what you are trying to do in your conditions.

Sorry. Thanks for the explanation regarding = and ==. I need 2 conditions to be met in order for the action to be performed. What I really need is to evaluate the issue for 3 sets of conditions then set the priority to one of 3 values based on the condition. e.g.

If

issue.resolution?.name == 'Entered into Product Backlog'

&

cfValues['Severity'] == "Level 1/Critical"

then

set issue.priorityId = '1'

else, If

issue.resolution?.name == 'Entered into Product Backlog'

&

cfValues['Severity'] = "Level 2/Severe"

then

set issue.priorityId = '3'

else, If

issue.resolution?.name == 'Entered into Product Backlog'

&

cfValues['Severity'] = "Level 3/Important"

then

set issue.priorityId = '4'

OK... so just to take the first one only, the condition you want is:

issue.resolution?.name == 'Entered into Product Backlog' && cfValues['Severity'] == "Level 1/Critical"

You can do that with 3 separate post-functions as you are doing, or you can work out the priority in the additional code with similar code.

Hi Jamie,

I'm having syntax trouble again. I need to add a condition to check for issue type = "New Feature" or issue type = "Improvement" and I can't get it right. I've tried issue.type?.name =="New Feature", issue.type?.value == "New Feature" , issue.typeid == 2 and a few others. Can you tell me what the correct syntax for this field is?

Thanks.

[ "New Feature", "Improvement"].contains(issue.issueTypeObject.name)

If you look at the javadoc for Issue you will find this...

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,760 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot