Forums

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

Automation: using If statement in smart value for "Edit work item" step

Michael Catmur November 25, 2025

Hi,

I have a Service Desk being used to record incidents where i need to record dates/times down to the second. 

In order to achieve this, i have: 

  • date fields for start (JTU_DateGMT) and end (JTU_DateGMTEnd) dates and
  • text fields for the time (using a mask to ensure the correct format) for start and end times (JTU_StartTimeofIncident_GMT, JTU_EndTimeofIncident_GMT). 

JTU_DateGMTEnd is deliberately options. Issues may be raised in advance of an issue being resolved. 

To make duration calculations (when there is an end date), i concatenate the data and time strings to make a ISO time format.. so 

JTU_StartDateTime_GMT_Concatenated = {{issue.JTU_DateGMT.format("yyyy-MM-dd").concat("T").concat(issue.JTU_StartTimeofIncident_GMT).concat(".000+0000")}}

...

However, for JTU_StartDateTime_GMT_Concatenated I need logic to do the following:

  • if no end date, assume the end date is the same as the start date
  • else, if there is an end date, use that value. 

I'm trying to to user IF logic within the smart tag, for JTU_EndDateTime_GMT_Concatenated, but am struggling to get it to output any value.

My most recent attempt has this smart value setting:

"Test: {{#debug}}{{#if issue.JTU_DateGMTEnd}}{{issue.JTU_DateGMTEnd.format("yyyy-MM-dd").concat("T").concat(issue.JTU_EndTimeofIncident_GMT).concat(".000+0000")}}{{else}}{{issue.JTU_DateGMT.format("yyyy-MM-dd").concat("T").concat(issue.JTU_EndTimeofIncident_GMT).concat(".000+0000")}}{{/}}{{/debug}}"

 

absolutely nothing gets written in the debug message... so ... 

a) if IF logic supported in smart tags like this, and 

b) any pointers if i'm messing up the syntax/approach for the IF?

anything else, before i shoot myself :-)

Many thanks

 

---

Jira Cloud

Company managed project

Untitled 2.pngUntitled 3.png

 

 

 

2 answers

1 accepted

3 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.
November 25, 2025

Hi @Michael Catmur 

The syntax you are using for the conditional expressions is incorrect; I recommend reviewing the documentation for the different possible syntaxes.

 

#1) The syntax which includes an else block looks like this, and does not support all possible inline functions.  Instead, use experimentation to confirm what works.  Please note the absence of the pound sign # at the start.

{{if(smartValueExpression, "value if True", "value if False")}}

 

#2) The other syntax only handles True cases, and it does use the pound sign # at the front.  And, there is no {{else}} modifier as you tried.  If you saw that {{else}} recommended by some non-Atlassian doc / tool (e.g., an AI bot guesser), I recommend not using that tool in the future.

This other syntax can handle many more smart value functions within the True block.

{{#if(smartValueExpression)}}value if True{{/}}

 

If the first syntax does not work for your smart value expressions, you could instead the second one, adding another clause which inverts the logical condition for your "else" case.

 

Kind regards,
Bill

Michael Catmur November 25, 2025

Thanks Bill, 

So the {{else}} defo had me on the wrong path. bad google. 

I think i'm now up against a limitation of this approach. 

...

 

just tested and this is now working:

 

{{#debug}}
{{if(issue.JTU_DateGMTEnd,
issue.JTU_DateGMTEnd.format("yyyy-MM-dd").concat("T").concat(issue.JTU_EndTimeofIncident_GMT).concat(".000+0000"),
issue.JTU_DateGMT.format("yyyy-MM-dd").concat("T").concat(issue.JTU_EndTimeofIncident_GMT).concat(".000+0000")
)}}
{{/debug}}

Like # people like this
0 votes
Robert DaSilva
Community Champion
November 25, 2025

Hi @Michael Catmur ,

Automation Smart Values support IF logic, found here: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/

I would recommend potentially switching to use the built-in If / else blocks found within the Condition block. This would be helpful to allow you to do this if/else on the Jira field itself, and then simplify your automation rule and smart value calculation. 

It also it a bit more maintainable having a more clear separation of actions.

Hope this helps!

Robert

Michael Catmur November 25, 2025

Thanks Robert.

I'm specifically trying to avoiding the built in IF / ELSE blocks as they get cumbersome to work with in a large automation (particularly in the the limited vertical workflow editor), so counterintuitively they can result in automation becoming less manageable.

If smart values can't work with my data, I may have to go in that direction, but i'd like to avoid it.

Might it be that the field being evaluated for in the first IF, is a "date" not a "string". if that's the case, do you know if the IF evaluation should evaluate it on the fly if converted as "issue.JTU_DateGMTEnd}}.format("yyyy-MM-dd").

I've tried this, but not had any success, and im suspicious that i may either have a syntax issue that i'm blind to, or i'm not using/converting data types correctly. 

... Any other suggestions?

Robert DaSilva
Community Champion
November 25, 2025

If that's the case, I would recommend the following:

  1. Create a Variable for the condition where the End Date is empty, and generate your new date there
  2. Create a variable for the condition where the end date is populated, and generate your new date there
  3. Using the 
    {{if(smartValueExpression, "value if True", "value if False")}}

    condition option, insert the two new Variables in the "Value if true" and "Value if false" areas.

This should help keep the calculation and concatenation distinct, while also allowing the use of the built-in IF function.

Michael Catmur November 25, 2025

Thanks. You and Bill both pointed me in the right direction. 

Like Robert DaSilva likes this

Suggest an answer

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

Atlassian Community Events