Forums

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

Jira Date diff automation

Sunny Kanojia June 18, 2024

 

Hi Team,

 

I used date diff query to automate RCA being recorded and it is giving a success response but the custom field that must be edited is not getting edited.

 

Screenshot 2024-06-18 at 2.43.07 PM.pngScreenshot 2024-06-18 at 2.43.14 PM.pngScreenshot 2024-06-18 at 2.43.25 PM.png

 

2 answers

1 vote
Tansu Akdeniz
Community Champion
June 18, 2024

Hi @Sunny Kanojia 

Welcome to the community.

Please first check how diff function is used from here: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/

It seems there is something wrong in your usage.

Also, take a look at this existing thread: https://community.atlassian.com/t5/Jira-questions/automation-for-date-difference/qaq-p/2343981

Don't forget to check Audit Logs.

If problem persists, share your formula here in text.

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

Hi @Sunny Kanojia -- Welcome to the Atlassian Community!

Adding to Tansu's answer:

There is definitely an error in what you show for using the diff() function to set the "RCA TAT" field.

Please post the smart value expression you have in that field so the community can offer suggestions.  Thanks!

Kind regards,
Bill

Sunny Kanojia June 19, 2024

Hi Tansu and Bill,

 

Thanks for your response. In the RCA TAT, which is a number field, I am trying to capture the difference in hours between two dates, both the events having date and time information. I am getting a success response of the query but the 'RCA TAT' field is still empty.

 The query I am using is :

{{(issue.customfield_10149)diff(issue.customfield_101649.hours}}

 

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

Please try this update as you had some misplaced parentheses: 

{{issue.customfield_10149.diff(issue.customfield_101649).hours}}

 

Like Sunny Kanojia likes this
Sunny Kanojia June 19, 2024

Screenshot 2024-06-20 at 9.10.41 AM.pngScreenshot 2024-06-20 at 9.11.04 AM.pngScreenshot 2024-06-20 at 9.12.11 AM.pngHi Bill, with the updated query, it is giving the success but automation is making the RCA TAT recorded to none, as before. Please advise.

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.
June 20, 2024

Here are some follow-up questions to try to diagnose this symptom:

  1. What type of project is this: company-managed or team-managed?  You may find that at the bottom-left of the screen expanding area.
  2. Are those custom fields configured in Jira or from a marketplace addon / app?
  3. Have you confirmed with admin functions both of those fields are date / time field types?
  4. Have you confirmed those are the correct custom field id values for the fields?
  5. Have you confirmed both fields have date / time values when the rule runs?  You may confirm that by writing both values to the audit log before the field is edited in the rule.
  6. Have you tried writing the diff() expression to the audit log to check if the expression is correct, but the problem is storing the result: {{issue.customfield_10149.diff(issue.customfield_101649).hours}}

 

0 votes
Harsh
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.
June 18, 2024

Hi @Sunny Kanojia 

Can you tell what field type is RCA TAT and what exactly you want. The automation is bit confusing.

Thanks!

 

Sunny Kanojia June 19, 2024

Hi Harsh,

 

Thanks for your response. In the RCA TAT, which is a number field, I am trying to capture the difference in hours between two dates, both the events having date and time information. I am getting a success response of the query but the 'RCA TAT' field is still empty.

 The query I am using is :

{{(issue.customfield_10149)diff(issue.customfield_101649.hours}}

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

Hi @Sunny Kanojia 

Instead of directly copying value, you can create a variable first with the smart value to calculate the difference.

And then add that created variable as a smart value {{variablename}} to RSA TAT field.

You can also log action to debug if the smart value mentioned above is actually giving the difference.

Thanks!

 

Like # people like this
Sunny Kanojia June 19, 2024

Hi Harsh,

 

Please can you elaborate how can i do this.

Harsh
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.
June 20, 2024

Sure,

Trigger: When issue transitioned 

Condition: Issue type equals 

Action: Create Variable. Lets call it as: datedifference, in smart value put the following: {{#=}} {{issue.date1.diff(issue.date2).days}}{{/}}

{{#=}} implies math formula just for context

Edit Action: Create a log action and put {{datedifference}} to debug if it calculating or not.

Edit Action: Edit Issue: Choose the RSA TAT field, and put the {{datedifference}}.

This should work because I have used the same mechanism several time.

In any case let me know if it works or not.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events