My Jira Automation isn't correctly calculating the field I want it ot

Gui Annunciacao November 2, 2023

I've introduced a new field in me project called "Weeks Duration." It is supposed to take a targeted end date and dubstract a targeted start date, and represent that value in weeks. 

 

So if I an issue's targeted end date is on Dec 15, and the targeted start date is on dec 1, then I want the duration to be Dec 15 minus dec 1. 

 

Here is the syntax I'm using.

{{issue.targetEnd.diff(issue.targetStart).weeks}}

 

The rule runs every time, but the value is never updated. Just shows nothing. Help?!

1 answer

1 accepted

0 votes
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 2, 2023

Hello @Gui Annunciacao 

Please show us your complete rule. Sometimes the problem has to do with the context in which the step is executed.

You can also use the Log action to print out smart values to the execution log for the rule, to confirm you are getting what you expect. 

For instance, are you sure that "targetEnd" and "targetStart" are actually returning the values from the expected fields? You can add a step like this to your rule:

Screenshot 2023-11-02 at 3.37.50 PM.png

If the step executes then in the rule execution log you will see

Target end is: 

followed by whatever value Jira was able to retrieve for the smart value. 

 

I suspect the problem is that "targetEnd" and "targetStart" are not actually the names of the fields, so Jira is getting no value back when using those smart values. Jira Automation will not necessarily tell you that it can't find the field you are trying to use. Instead it will just use null as the value.

The field name is usually exactly what you see on the screen for the label of that field. If the field label in the issue shows as Target End, then you need to be using {{issue.Target End}} instead.

Gui Annunciacao November 3, 2023

Thank you for the reply. I've attached below screen shots with the updated name of the input methods, the complete rule, and the new log action to show that the target end is correct Screen Shot 2023-11-03 at 1.55.58 PM.png

 

I'm still not getting any results. Any other ideas? 

 

Screen Shot 2023-11-03 at 1.47.52 PM.pngScreen Shot 2023-11-03 at 1.48.34 PM.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 3, 2023

In your automation rule I see that you did have a Log action to print the value of Target end.

I suggest that you also add Log actions to print the following:

- Target start

- {{issue.Target end.diff(issue.Target start)}}

- {{issue.Target end.diff(issue.Target start).weeks}}

And then show us the full output of the Audit Log.

 

Do both date fields have values?

Is the difference between them 1 week or longer?

Gui Annunciacao November 6, 2023

The problem is with the diff expression. Check out my logs below. 

 

Screen Shot 2023-11-06 at 2.59.26 PM.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 6, 2023

The syntax appears to be correct.

Can you check the field types for those two fields in the Custom Fields screen and confirm that they are Date Picker fields?

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 6, 2023

Hi @Gui Annunciacao 

Adding to Trudy's answer...

I believe some of those advanced roadmap fields are text in automation rules, not date or date/time type.  And so to be used in a diff, they must be converted first with toDate

{{issue.Target start.toDate.diff(issue.Target end.toDate).weeks}}

Kind regards,
Bill

Like Challa S likes this
Gui Annunciacao November 6, 2023

Confirmed. They are date pickersScreen Shot 2023-11-06 at 4.18.12 PM.png

Gui Annunciacao November 6, 2023

This worked, thanks!!

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 6, 2023

For clarity, do you mean @Bill Sheboy 's suggestion to format the fields worked?

Gui Annunciacao November 6, 2023

Yes, Bill's suggestion worked. 

It's a little confusing, because from my screen shot, it looks like target end and target start are already dates, and wouldn't need to be converted. 

Like Bill Sheboy likes this

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