Help converting variable to date

Roger Mcgregor July 18, 2024

Hello, I am trying to convert in jira automation, a variable into a date. The variable is caught from the issue description field, where a due date is set as plain text. Next I try to manipulate the date with syntax:

{{Variable.toDate.plusDays(14).format("dd.MM.yyyy")}}

When I try to print out the result, it returns as empty. Log only returns the syntax with any explanation.

The idea is to compare the date from the description (variable) with and if else statement, with todays date.

 

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 Leaders.
July 18, 2024

Hi @Roger Mcgregor 

For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected.  Those will provide context for the community to offer ideas.  Thanks!

Until we see those...

From what you describe and the smart value expression shown, it is likely the variable is not evaluating to a date correctly.  Please try writing the variable to the audit log to confirm that.

When actions in rules have conversions like toDate that do not work, they collapse to null and "fail" silently with no error in the log.

Kind regards,
Bill

Roger Mcgregor July 19, 2024

Sure here's screenshots of the workflow. And the summary field on issure is set to "start 17.10.2024 end".

1.png2.png3.png4.png

My goal is to create a scheduler that compares dates daily, and does magic if the if else statement is met or not

 

 

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.
July 19, 2024

This confirms the initial parsing to get the date in the variable is incorrect.

Please show an example of, and write to the audit log, the Summary for the trigger issue as that will help confirm how to adjust the parsing.  That will also help when the rule fails in the future as...

 

This is a risky rule / solution approach.  Putting a date value in the summary in a way that could be interpreted as either dd-MM-yyyy versus MM-dd-yyyy by a person may cause entry or understanding errors.  Is this date entered by a person or created with some automated source?

 

Next, there is an error in your condition as it tries using jiraDate as a value rather than nowjiraDate is a format.  (Please see below.)

 

Finally, to avoid the risk of a typo / error in the date comparisons, I recommend using jiraDate rather than the format() command.  For example

  • smart value condition
    • first value: {{DateVariable.toDate("dd-MM-yyyy").jiraDate}}
    • condition: is greater than
    • second value: {{now.plusDays(14).jiraDate}}

 

Roger Mcgregor July 25, 2024

Hello,

Here's more screenshots. from summary, modified dates and log.

1-1.png   <--Summary

2-2.png3-3.png

The dates come from an automated message.

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.
July 25, 2024

Would you please post your current, updated rule in a single image?  Posting in a single image will confirm the step order / context. 

If the rule is too large for one browser page, you could use a scrolling page browser addon or app to capture the image.

Suggest an answer

Log in or Sign up to answer