Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to use smart value in if condition for automation

Nicolas Courvoisier September 21, 2023

Hello,

I would like to have automation when a pull request is created, the status is changed to "In Review". However, that should not happen if it's only draft pull request. It can be identified with a pull request title containing "Draft". I also exclude tickets of type "Incident" which have a different workflow. 

No add-on tool possible.

The following automation rule returns "some errors" but only details "no actions were performed". Can someone please help me?

ShareX_Nicolas_ExaltedBrownbutterfly.png

1 answer

1 accepted

0 votes
Answer accepted
Bill Sheboy
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.
September 21, 2023

Hi @Nicolas Courvoisier 

Would you please post an image of the audit log details showing the rule execution, including one with the error?  That may provide some context to understand this symptom. 

And as the rule appears longer than what you show, could you also post an image of the complete rule, ideally in a single image?

Thanks!

Kind regards,
Bill

Nicolas Courvoisier September 21, 2023

Hello @Bill Sheboy 

Here is below the audit log.ShareX_Nicolas_SmoothAtlanticspadefish.png

There is nothing more for the rule at the bottom of screen.

Thank you, best regards

Nicolas

Bill Sheboy
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.
September 21, 2023

Thanks for that information...and I am fairly confident your conditions may be the problem.  If you post images of your condition details I can confirm that.

What you show leads me to believe you have this in a condition:

{{pullRequest.title.toLowerCase().indexOf("draft")>0}}

That is invalid, as the greater-than sign is not valid in that expression.

There are at least 2 ways to test that condition: 

  • use an advanced compare condition and test
    • first value: {{pullRequest.title.toLowerCase().indexOf("draft")}}
    • condition: greater than
    • second value: -1
  • use an advanced compare condition, with an inline, greater-than test
    • first value: {{pullRequest.title.toLowerCase().indexOf("draft").gt(-1)}}
    • condition: equals
    • second value: true
Like Nicolas Courvoisier likes this
Nicolas Courvoisier September 21, 2023

Hello

Please find below my condition, I used indeed a simple "JQL condition":

ShareX_Nicolas_RunnyVixen.png

I switched to "Advanced compare condition" with your 1st change:

  • first value: {{pullRequest.title.toLowerCase().indexOf("draft")}}
  • condition: greater than
  • second value: 0

and am waiting for the next PR created. I keep you posted. Many thanks.

Like Bill Sheboy likes this
Nicolas Courvoisier September 22, 2023

@Bill Sheboy it works like a charm now.

Many thanks for your precious help!

Like Bill Sheboy likes this
Nicolas Courvoisier September 28, 2023

Hello,

Unfortunately, the positive match condition with the PR title did not work. This couldn't be tested previously (requires a PR with "draft" in title). 

As you can see PR contains the word "DRAFT" but the if condition isn't matched.

Any idea? Thank you 

ShareX_Nicolas_HotNaga.png

Bill Sheboy
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.
September 28, 2023

My apologies, Nicolas...It appears indexOf() returns a 0-based value.  That is, the first position is at 0.  When nothing is found, it returns -1.

And so the second value in that condition should be changed to -1 to help when draft is in the first position.

I will update the earlier posts also.

Nicolas Courvoisier September 28, 2023

Ok super, I have modified it. Many thanks again for your support. Let's wait for a draft PR to confirm.

Like Bill Sheboy likes this
Nicolas Courvoisier October 6, 2023

It has worked well :) 

Again thanks @Bill Sheboy 

Like Bill Sheboy likes this
suha_shakaa July 22, 2024

Hello

I tried this and it didn't work for me unfortunately the status remains unchanged and the audit log give me this. Can someone help pleaseimage.png

Bill Sheboy
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 22, 2024

Hi @suha_shakaa -- Welcome to the Atlassian Community!

As this is an older thread, I recommend creating a new question and perhaps add a link back to this one.  That will ensure the maximum number of people see it to offer suggestions.

When you post your new question, please include:

  • what problem are you trying to solve; that is, "why do this"
  • an image of your complete automation rule, in one image file
  • images of any relevant trigger, actions, branches, or conditions
  • an image of the audit log details showing the rule execution
  • explain what is not working as you expected, and how you know that

Those will provide context for the community to offer help.  Thanks!

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events