Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

JIRA Automation does not recognize value as number every other time Edited

We have a need to keep track of how many days each developer has spent in an operational role supporting our support team versus how many days they have spent in a project role developing new functionality.  The operational role is known as Primary Responder or P1

I have created a new card type, known as "People".  I have created the following custom fields:

10131 P1 Days

10132 Joined Team

10133 Previous Team Days

10134 Previous Team Join Date

10137 previous P1 days

The automation rule looks like this:

1. When people card transitioned from x to y (statuses that I'm not delineating in this post)

2. and the Issue type = People

3. Then: Edit issue fields "Previous Team Days": 

{{issue.customField_10132.diff(issue.customField_10134)days}}

Description: Joined team date minus previous join team date in days

4. AND Edit issue fields "Previous P1 Days": 

{{customField_10131}} 

Description: Copy P1 days to Previous P1 days

5. AND Edit issue fields "P1 Days": 

{{customField_10133}}+{{customField_10137}} 

Description: Add Previous Team days to Previous P1 days

 

Now, something very strange happens.  It works every other time, and fails every other time.  However, there is an error message every time that says:

Failed to get value for issue.customField_10132.diff(issue.customField_10134)days: {{issue.customField_10132.diff(issue.customField_10134)days}}

 

So for testing purposes, I set the following:

Joined Team: 2021/04/20

Previous Team Join Date: 2021/04/18

Previous Team Days: 2

Previous P1 Days: 2

P1 Days: 2

 

So then, I would expect the progression to be:

2 2 2 (initial state)

2 + 2 = 4 (this works)

2 + 4 = 6 (instead I get 2 4 4)

On next move i get 2 + 4 = 6

Next move I expect 2 + 6 = 8, but I get 2 6 6.

 

So confused.

 

2 answers

0 votes
John Funk Community Leader Apr 21, 2021

Hi Jason,

Not sure this contributes to the problem with just a cursory glance, but I noticed this in Step 4:

{{customField_10131}}

It probably should be 

{{issue.customField_10131}} 

got it.... I'll change that over.  I was wondering about that because I saw it both ways, and wasn't sure which was correct.

So I'm going to answer my own question, because I ended up figuring it out.  Just in case someone runs into this in the future.

 

This is a combination of two problems:

1. When running a rule, it appears that it runs the rule based on what the value of a field was when you started running the rule, not its value based on previous steps in the rule.  This can be solved with the action "Re-fetch issue data".

2. This one is frustrating to me, but it appears that when you use 

{{issue.datefield.diff(issue.datefield)days}}

it does not return the result as a number.  I cannot figure out how to force this directly.  However, I added another field called "Previous team days text" and made it a text field.  Then I added a step that has:

{{#=}}{{issue.customField}}{{/}}

which converts the text in the text field to a number.  

 

It seems that there should be a more direct way to do this, but after hours of messing with this yesterday I managed to get it working this morning.

Hi @Jason J_ Fedelem 

Yup, that edit/use field behavior in rules can be solved with the re-fetch action...although it slows the rule quite a bit.  When possible, you may also store a calculated value in a Created Variable when you plan to re-use later in the rule.

Also consider using default value handling when you need a numeric.  This can address any null values in your fields.  For example: {{issue.myField|0}}

Best regards,

Bill

Thanks @Bill Sheboy .... I'll try the created variable approach.  This rule I have is a HUGE Rube Goldberg machine.... the rule takes around 45 seconds to run.  I ended up having to refetch data 3 times, which is probably most of the length of the rule.

This rule will only get run a couple of times a month, so in this case it's not a huge problem, but I anticipate doing this kind of thing more so a better approach is needed long term.

Thanks for the help.

Like # people like this

I agree, and... you may want to read about the service execution limits and performance recommendations.  When debugging a longer running rule, you could start piling up execution time and cause a service breach.  Web requests, branches, re-fetches, and chained-rules are the usual suspects for time usage, so using something like Created Variable can help with a couple of those.

https://support.atlassian.com/jira-software-cloud/docs/what-are-service-limits/

https://support.atlassian.com/jira-software-cloud/docs/optimize-your-rules/

https://blog.codebarrel.io/how-to-optimize-your-automation-for-jira-rules-for-best-performance-4b5fdf751faa

Like John Funk likes this

Thanks Bill, I'll check it out.

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

254 views 2 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you