Forums

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

Automation for Jira Server: Problem with IF conditional statements

Jira Administrators November 5, 2022

I have a custom field called "p-card: missing receipts".  It's a long text field and its ID is 29301.

I want automation to send an email.  If there is a value in that custom field, I want "hello" displayed in the email, otherwise nothing.

I have tried the following but they either display nothing when there is a value in the custom field, or they throw an error:

{{if(not(customfield_29301.isEmpty)),"hello")}}

{{if(p-card: missing receipts,"hello")}}

{{if(customfield_29301)}}hello{{/}}

I used the following documentation: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/

 

2 answers

1 accepted

0 votes
Answer accepted
Jira Administrators November 8, 2022

Sebastian - 

Thank you. 

1. After much experimenting, I determined the problem: a single-line conditional statement must begin with #if, not if.  This statement works:

    {{#if(not(issue.customfield_29301.isEmpty))}}hello{{/}}

Remove the # and this statement throws an error:

    {{if(not(issue.customfield_29301.isEmpty))}}hello{{/}}

It would appear that this documentation is incorrect: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/

 

2.  My experiments indicate that "issue." has no effect in this situation.  All of these worked fine:

  • {{#if(not(customfield_29301.isEmpty))}}hello{{/}}
  • {{#if(not(issue.customfield_29301.isEmpty))}}hello{{/}}
  • {{#if(not(P-card: missing receipts))}}mega hello{{/}}
  • {{#if(not(issue.P-card: missing receipts))}}mega hello{{/}}

 

Thanks again

Lionel

Sebastian Krzewiński
Community Champion
November 9, 2022

Thanks Lionel for and explanation!

0 votes
Sebastian Krzewiński
Community Champion
November 6, 2022

Hi @Jira Administrators 

 

You should use:

- issue.customfield_29301 instead of customfield_29301

- issue.p-card: missing receipts

 

Please check this doc - https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#Available-properties.1

 

Regards,

Seba

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events