Forums

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

Checking if components is empty

Harmeet Singh March 21, 2022

I am trying to set up an automation job which sends out an email to the reporter of the issue is certain fields are missing data. Here's the email template I use in the send email section of the automation.

 

This epic is missing the following fields
<ul>
{{#if(issue.fixVersions.isEmpty)}}
<li>No fix version is assigned to the epic. Epic is empty</li>
{{/}}
{{#if(not(exists(issue.fixVersions.name)))}}
<li>No fix version is assigned to the epic</li>
{{/}}
{{#if(not(exists(issue.components.name)))}}
<li>The epic does not have any components assigned.</li>
{{/}}
{{#if(components.isEmpty)}}
<li>The epic does not have any components assigned. Component is empty</li>
{{/}}
</ul>

 

the fixversions work but the components conditional statement does not get triggered. 

I have logged components.name and it is indeed empty so I am not sure why the message above is not displayed in the email. 

 

1 answer

0 votes
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.
March 21, 2022

Hi @Harmeet Singh 

You do not show your entire automation rule, and I wonder if there is a context problem where the email is seeing another issue.

Perhaps add the missing prefix for issue. such as:

{{#if(issue.components.isEmpty)}}
<li>The epic does not have any components assigned. Component is empty</li>
{{/}}

If that does not work, you could try checking the size as the components field is a list.

Kind regards,
Bill

Harmeet Singh March 22, 2022

The issue is that the message should be displayed when there are no components (empty object) or fixversions but that is not working.

 

I added the prefix and that does not work either. 

Harmeet Singh March 22, 2022

So the whole block of smart values looks like this 

 

This epic is missing the following fields
<ul>
{{#if(issue.fixVersions.name.isEmpty)}}
<li>No fix version is assigned to the epic. Epic is empty</li>
{{/}}
{{#if(not(exists(issue.fixVersions.name)))}}
<li>No fix version is assigned to the epic</li>
{{/}}
{{#if(not(exists(issue.customfield_12313140)))}}
<li>Epic is is not linked</li>
{{/}}
{{#if(not(exists(issue.Team)))}}
<li>The epic is not assigned to a team</li>
{{/}}
{{#if(not(exists(issue.components.name)))}}
<li>The epic does not have any components assigned.</li>
{{/}}
{{#if(issue.components.isEmpty)}}
<li>The epic does not have any components assigned. Component is empty</li>
{{/}}
</ul>

 

So from all of the above conditionals only the team and the customfield displays a message. All the other conditionals generate a null even if the fixversions or components have no value assigned. 

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.
March 22, 2022

I am using Jira Cloud, and all of those worked for me in a test rule.  Perhaps this is something different about the smart values for Jira Server/Data Center.

I suggest working with your site admin to submit a ticket to Atlassian Support to see what they can find: https://support.atlassian.com/contact/#/

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events