Forums

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

Jira Automation: smart value for checking if field is Empty in email

Nicole Wang March 19, 2024

Hi Team,

When I create an automation to send the email to show Jira report, I'm encountering one problem. I want to include two parts in one email. The first part is to show a list of jira whose fixVersion is not empty; and empty fixVersion Jira list in second part. When I try to use below condition to split two parts, I cannot get what expected. Even the field is empty, it cannot return True.

{{#if(equal(issue.fixVersions,null))}}

{{#if(equal(issue.fixVersions,""))}}

{{#if(equal(issue.fixVersions,invalid reference))}}

Could you please give any suggestion here? Thanks!!

1 answer

0 votes
_A9_ William Kennedy
Contributor
March 19, 2024

The question was about including two parts in an email sent by a Jira automation rule: one part for Jira issues with a non-empty fixVersion field, and another for issues where fixVersion is empty. The issue encountered was that the conditions used to split the two parts didn't work as expected, and even when the fixVersion field was empty, it didn't return true.

The conditions tried were:

  • {{#if(equal(issue.fixVersions,null))}}
  • {{#if(equal(issue.fixVersions,""))}}
  • {{#if(equal(issue.fixVersions,invalid reference))}}

The solution involves using the right smart value syntax to check if a field is empty or not. Jira Automation smart values can be tricky, especially when dealing with fields that can have multiple values like fixVersions.

Here's how to approach it:

Check if fixVersions is empty: To accurately check if fixVersions is empty, you can use the .isEmpty() method. This method is specifically designed to handle cases where a field may not have any value.

{{#if(issue.fixVersions.isEmpty)}}
// Actions to perform if fixVersions is empty
{{else}}
// Actions to perform if fixVersions is not empty
{{/if}}

Ensure the field name is correct: Double-check the field name fixVersions. In Jira, field names are case-sensitive and must match exactly.

Additional checks for null or undefined values: The methods tried (equal(issue.fixVersions,null), equal(issue.fixVersions,""), and equal(issue.fixVersions,invalid reference)) are not the recommended approach for checking if a list-type field like fixVersions is empty.

By using the .isEmpty() method, the automation rule should correctly execute actions based on whether the fixVersions field is empty or contains values.

Nicole Wang March 19, 2024

Hi wkennedy,

This works for issue.fixVersions. However, if I apply this to inwardIssue's fixVersions, it doesn't work. When I use {{inwardIssue.fixVersions.name}}, it return an empty set [], how to verify inwarIssue's fixversion is empty? Thanks!

_A9_ William Kennedy
Contributor
March 19, 2024

Here's an approach to try:


{{#if(inwardIssue.fixVersions.isEmpty)}}
// Actions to perform if inwardIssue's fixVersions is empty
{{else}}
// Actions to perform if inwardIssue's fixVersions is not empty
{{/if}}

If the .isEmpty() method does not behave as expected with inwardIssue, consider the following troubleshooting steps:

  • Check for Null or Undefined: Before checking if it's empty, ensure that inwardIssue and inwardIssue.fixVersions are not null or undefined. Sometimes, the issue might be that inwardIssue doesn't exist or doesn't have a fixVersions field due to configuration.
  • Debug Output: Use a log action in your Jira automation rule to output the value of {{inwardIssue.fixVersions}} to confirm it's what you expect. This can help identify if the issue is with the data or the condition logic.
Kalyan Sattaluri
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 19, 2024

Hello @Nicole Wang 

For the linked issues, you can only get, key, summary, status, priority, issuetype available but not fixversion, so it will return empty.

 

Nicole Wang March 19, 2024

Hi wkennedy/Sattaluri,

{{inwardIssue.fixVersions.name}} can return concrete thing if version is not empty. But I'm confused that when I apply isEmpty to it, it return empty rather than true/false.

Kalyan Sattaluri
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 19, 2024

@Nicole Wang 

Oh wow, never realized we coudl access linkedissues fix version.

Please check like below..

{{#if(issuelinks.inwardIssue.fixVersions.name.isEmpty)}}true{{/}}

Like _A9_ William Kennedy likes this

Suggest an answer

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

Atlassian Community Events