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

Jeannette Lamb May 19, 2013

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

0 votes
Answer accepted
Jeannette Lamb May 20, 2013

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
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.
May 19, 2013

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.

Jeannette Lamb May 19, 2013

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'

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.
May 20, 2013

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.

Jeannette Lamb June 30, 2013

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.

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.
July 2, 2013

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

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

SMAtlassianMber August 16, 2019

@JamieA - I am having a similar issue with my If And Else Statement.  Any ideas why this isn't working? 

if (skillsetField == "Application Testing")
&& (getAction().id == "381")
{
BusImpactField.setRequired(true)
BusImpactField.setHidden(false)
BusImpactField.setHelpText ("Business Impact must be filled in once moved to 'Ready for Functional Testing'")
}
else {
BusImpactField.setRequired(false)
BusImpactField.setHidden(true)
BusImpactField.setHelpText ("")
BusImpactField.setFormValue(defaultValue)
}

Suggest an answer

Log in or Sign up to answer