Forums

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

If Statement that compares the start of day with a custom Date/Time value.

Delaney Bannon
January 14, 2025

I'm trying to have an if statement that runs if a date/time picker value, "Last Status Change" is after the start of today's date. This was my most recent attempt:


{{#if(now.toDateTimeAtStartOfDay.isBefore("Last Status Change"))

Test

{{/}}

 

This permutation has errors, but I've tried dozens of different variations and I'm out of ideas. I think this is just the cleanest psuedocode example for showing what I'm trying to do. I've also tried getting a diff between "now" and "Last Status Change" but it would appear blank.

 

Any thoughts or suggestions would be appreciated.

1 answer

0 votes
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 Champions.
January 14, 2025

Hi @Delaney Bannon -- Welcome to the Atlassian Community!

Is "Last Status Change" a custom field you have added and which is a date / time type field?

If so, please try this:

{{#if(now.toDateTimeAtStartOfDay.isBefore(issue.Last Status Change))}}Test{{/}}

You will need to confirm the exact smart value (or custom field ID) to use for your field for the expression to work. 

That may be done using this how-to article: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

Kind regards,
Bill

Delaney Bannon
January 15, 2025

Hi Bill, thanks for the response. It set me on the right track. I found the code that runs properly. For anyone else's benefit, it ended up being:

{{#if(now.toDateTimeAtStartOfDay.isBefore(customfield_xxxxx))}}

Test

{{/}}

 

 

It doesn't work with issue.Last Status Change, issue."Last Status Change", or any other variation. 

And to make a correction, I figured out the source of the error which was a missing {{/}} at the end of the statement.

Like Bill Sheboy likes this
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 Champions.
January 15, 2025

Well done!

Smart values are name, spacing, and case-sensitive, and frequently do not exactly match the field's display name on the issue pages.  When an incorrect one is used, that returns as null.  And even when the correct smart value is used, some are not supported and the custom field ID must be used in rules.

Like Delaney Bannon likes this
Delaney Bannon
January 15, 2025

I've been learning that over the past few days. I'm curious if there's a fast way to write something and see what it would output. Since I've been setting up an automated email my method has been to edit the email body and then schedule it for a minute or two from the current time. It's a bit slow for a test case. Any other suggestions or should I make a separate question?

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 Champions.
January 15, 2025

Certainly!  To do that, please try the Log actionhttps://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Log-action

I often start many rules like this to test-as-I-go:

  • trigger: scheduled (with or without JQL)
  • action: log some smart value expression

With that, I can rapidly experiment to get the expression working...and it doesn't consume a rule "usage" count because the rule does nothing actionable.  When it works as needed, I change the trigger and incrementally add actions / conditions to experiment further until done.

 

Like Delaney Bannon likes this
Delaney Bannon
January 15, 2025

Thank you!

Suggest an answer

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

Atlassian Community Events