Hi everyone,
I set a automation rule to compare value between 2 date picker field, if it's less than 3 days, then set another field value to 5, if between 3 and 7 days, set to 4, etc.
Here is the smart value I put in {{issue.Start Date (migrated).daysBetween(issue.Contained Date).abs}}
However, no matter what dates I pick, it all passed first if block (less than 3)
Unable to resolve this even I tried solutions that provided by AI, anyone can help?
Thanks in advanced
Jack
Hi @Jack Yang ,
Replace the smart value with:
{{issue.migrated.diff(issue.Contained Date).days.abs}}
and keep the rest of the automation unchanged.
This worked successfully in my instance. I've attached a screenshot below for reference.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jack,
The problem is the smart value itself: daysBetween isn't a function in Jira
automation, so the whole expression never resolves to a number. With the left
side of your "less than 3" check blank, that first branch passes every time —
which is exactly what your audit log shows.
There's a single date-difference function, .diff(), and you append the unit,
then .abs:
{{issue.Start Date (migrated).diff(issue.Contained Date).days.abs}}
(order is unit-then-abs — straight from the docs, e.g.
{{now.diff(issue.created).days.abs}})
Two things worth checking while you're in there:
1) Confirm it actually resolves. Add a "Log action" (or write it to a temp
field) containing just that smart value and run the rule once — you should
get a number like 5, not a blank and not the raw {{...}} text. If it comes
back blank, the field reference is the culprit: "Start Date (migrated)"
with
the space and parentheses can be unreliable, so try the customfield_XXXXX
id
instead, or add .toDate("yyyy-MM-dd") before .diff() if that migrated field
is being returned as text rather than a date.
2) Check the branch logic. If those are separate "if" blocks rather than one
If / Else-if chain, more than one can fire. For "<3 → 5, 3–7 → 4, …" put
them
in a single If / Else-if and order them narrowest-first so the ranges don't
overlap.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.