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:
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:
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
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
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}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If that's the case, I would recommend the following:
{{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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks. You and Bill both pointed me in the right direction.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.