Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

If then else for comments / emails

John McConnell June 7, 2024

Hello all;

I have banged my head. (still a newbie)

I want to write a comment or send email to include:

 

  • Release / Fix Version:  {{If Fix Version is empty, then "Release is TBD", else Fix version name}}

I have tried about 15 different examples found all over the place but not having any luck.

Can you point me in the right direction?

 

2 answers

1 accepted

0 votes
Answer accepted
John McConnell June 11, 2024

Closing:

It sounds like what I'd like accomplish is not possible with a comment or email.  Which is fine, I don't want to waste time if not possible.

0 votes
Trudy Claspill
Community Champion
June 7, 2024

Hello @John McConnell 

Were you making use of this reference?

https://confluence.atlassian.com/automation/jira-smart-values-conditional-logic-1081351607.html

It does not appear that the logic supports an else condition for Jira Data Center.

Does the structure of your rule enable you to use an If/Else Block condition instead, and format two different messages?

John McConnell June 7, 2024

Yes, I have attempted your recommendaiton link, but no data.

Blocks don't seem to be an option here.

example of message/email

{{Fix Version/s.value}} value
{{Fix Version/s.name}} name
{{Fix Version/s}} plain


{{#if(Fix Version/s.value.isEmpty)}}
Release - TBD value
{{/}}

{{#if(Fix Version/s.name.isEmpty)}}
Release - TBD name
{{/}}

{{#if(Fix Version/s.isEmpty)}}
Release - TBD field only
{{/}}

 

Trudy Claspill
Community Champion
June 7, 2024

Can you show us your entire rule? We are missing some information about the context within which you are trying to use this code.

If the context of this code is such that the action has a single issue in context then to reference the Fix Version/s field you should be using the smart value

{{issue.fixversions}

Fix Version/s is also a multi-value field, so if you want to look at the name of a specific Fix Version within that field you have to identify which one you want.

Reference: https://confluence.atlassian.com/automation/jira-smart-values-issues-993924860.html

I think you should be able to use 

{{#if(issue.fixversions.isEmpty)}}
Release - TBD value
{{/}}

And you should be able to use

{{#if(not(issue.fixversions.isEmpty))}}
{{issue.fixversions.first.name}}
{{/}}

 

If the Fix Version/s field contains more than one value, how do you know which one you want to include in the message?

 

Or you could use an If/Else condition block in your rule, potentially

Screenshot 2024-06-07 at 2.57.54 PM.png

John McConnell June 7, 2024

Hello thanks for the feedback.

The "code" will go in an email out to a distro of users but here is the comment with your code recommendation.

image.png

image.png

Trudy Claspill
Community Champion
June 7, 2024

If you are going to use an If/Else Block condition like the example I provided, then you would not need the {{#if(.... {{/}} syntax within the message/comment content.

Just use the plain text:

Release - TBD

Like Bill Sheboy likes this
John McConnell June 10, 2024

Hello Trudy;

This isn't a block workflow for the fix version, it is an email that gets triggered when the status is ready for dev, then we send an email with information, including the fix version to our business partner.  So that is why I want to formulate the if value is empty then something, else value.

It sounds like what I'd like accomplish is not possible with a comment or email.  Which is fine, I don't want to waste time if not possible.

Trudy Claspill
Community Champion
June 11, 2024

I think what you want to do is possible. I'm not clear why you don't think it is possible.

In this example I used the Comment action but you could use the same syntax in a Send Email action. The rule makes one type of Comment if Fix Version/s is empty, and another Comment listing the Fix Version/s values if the field is not empty.

 

Screenshot 2024-06-11 at 1.45.17 PM.png

Suggest an answer

Log in or Sign up to answer