Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,418
Community Members
 
Community Events
184
Community Groups

Updating calculated number field using automation

I need to calculate how many days it was since the risk became actualized Issue.

when Risk becomes the Issue, we set the date "Issue Date"

I need to calculate the number of days between that date and today - and record it in "Days in" scripted field.

I tried to use Edit Issue action and set this field using this script:

{
"fields": {
"Days in": { "value": {{issue.customfield_10803.diff(issue.customfield_10820).days}}
}
}

No bueno! what am I doing wrong?

3 answers

Made following changes:
change 1.jpg

Result looks like this:

Result 2.jpg

Checking "successful" issues - still empty customfield_10821 (which is a NUMBER field).

 

(Thank you for your help, Florian)

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.
Apr 19, 2023

Hi @Lana Decker 

Would you please post images of your complete rule and the audit log details showing the rule execution?  Those may provide some context for what you are observing, and give the community ideas on what to suggest.  Thanks!

Until we see that...

This could be a scoping problem, based on where you are performing that date diff() in the rule.  It could also be a timing problem, if the issue you are using was just created.

Kind regards,
Bill

I posted a few  - answering questions from Florian, making changes per his suggestions. 

To address your points:

This could be a scoping problem, based on where you are performing that date diff() in the rule.  - I am trying to set a number field from EDIT action , triggered on schedule (see screenshots). 

It could also be a timing problem, if the issue you are using was just created. - no, most tickets are over a week old or older, only one is new.

0 votes
Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 19, 2023

Hi @Lana Decker 

Have you try to use the smart value below ?

 

{{now.diff(issue.created).days}}

 

Do not use the advancedediting but select the filed in the list and populate the field with the value above.

 

Reagrds

Thank you for your suggestion! 


Days in is a scripted field type and its not selectable - so I created another field (number type)

Using {{now.diff(issueID=10821).days}} - I would expect to get number between date field 10821 and today in days - but get no errors, no result

Using {{now.diff(issue.created).days}} - I would expect to get number between that date and today in days - but get no errors, no result.

 

Automation says success, but the field is empty. 

Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 20, 2023

{{now.diff(issueID=10821).days}}  is not valid you should use

{{now.diff(issue.customfield_10821).days}} 

 

When you say no result, is that there is nothing displayed or the field is empty when you try to edit it ? Is the field on the view screen ?

 

Regards

Field is on all screens (or a single screen we use for create, edit and view).

I edited query per your suggestion and get this when rule is triggered manually:

result.jpg

Checking any of the "successfully edited" issues i see that field is null in all of them.

Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 20, 2023

I would say that the field with id 10821 do not have context for the porject you are trying to apply the automation on.

Can you share the automation definition as well ?

If it didn't exist I would not be able to set it manually - but I can (also it wouldn't appear on the screen in the first place).

Rule scope is All projects. 

I tried to run it as me (god admin) and service god admin account with same result.

Rule.jpg

Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 20, 2023

Can you add an action "Log action" before the edit and copy paste what you have in the Days as Issue, {{now...... ?

 

So you will be able to see in the audit log of the value return by the smartvalue to see if it's what is expected.

What is the type of the field with id 10821 ?

Also you can update the JQL with something like Key = ISSUe_KEY in the test phase to try it on 1 issue instead of 500 or more.

 

Regards

change 1.jpg

result:

Result 2.jpg

Checking "successful" issues - still empty customfield_10821 (which is a NUMBER field).

Targeting specific issue: 

Result 3.jpg

issue history , activity has no changes - and field is still empty, but editable manually.

Sebastian Mondry
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Apr 27, 2023

Hi @Lana Decker

This is quite unusual, as I can't see anything wrong with your rule. 

Screenshot 2023-04-28 at 3.52.39 pm.png

Tried replicating something similar, whereby I have a schedule rule which uses JQL to search for a single issue, I then Log out {{now.diff(issue.created).days}} and as you can see, get the desired value of -63.

Would you mind reaching out to the Atlassian support team https://getsupport.atlassian.com/ ? They can look at your instance and understand what's going wrong. 

Thanks !

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events