Troubleshooting Jira Automation Rule for Date Calculation with Review Frequency

Abdur Rehman January 24, 2025

 

Hi @Stefan Salzl 

 

I am currently working with an object in the IT Infrastructure schema, and I’m trying to update the "Next Periodic Review Date" by adding the "Review Frequency" (integer) to the "Last Periodic Review" (date) field.

 

I have configured the rule as follows and reviewed the audit logs:

{{object.Last Periodic Review Date.plusYears(object.Review Frequency).format("MM/dd/yyyy")}}

The rule successfully retrieves the correct object when triggered, and the values are fetched correctly. However, when using this rule, it returns NULL for the "Next Periodic Review Date". When I manually input plusYears(4) instead of plusYears(object.Review Frequency), it works as expected

 

Could you kindly suggest what might be causing this issue with the smart value?

Thank you in advance for your helpJIra Service Management.pngJIra Service Management 1.png

2 answers

1 accepted

1 vote
Answer accepted
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 24, 2025

Hi @Abdur Rehman - welcome to the community,

I don´t know the field type of your field "Review Frequency". Even though it holds a number doesn´t mean it´s configured as number or returning a number when used it´s value.

Could you please try the following:

{{object.Last Periodic Review Date.plusYears(object.Review Frequency.asNumber).format("MM/dd/yyyy")}}

 

Best
Stefan

Abdur Rehman January 27, 2025

Hi @Stefan Salzl

Thank you for taking time to look at it. However, unfortunately it did not work either. I checked the "Review Frequency" attribute, and it is set to Integer too. I doubt if plusYears() function can only take Integer as an argument?

I could not find any documentation that refer to plusYears() handling smart value as an argument i.e. plusYears({{Smart value}}).

Thank you again for your response!

 

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 27, 2025

@Abdur Rehman 

did you at least try to verify or is this just your guess?

.plusYears() can take smart values. I‘ve done that alteady with other examples/field. But maybe that‘s a specific to assets.

Best
Stefan

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.
January 28, 2025

@Abdur Rehman please look again at the suggestion from @Stefan Salzl ...

You have added unnecessary curly-brackets inside the function call for plusYears().

Like Stefan Salzl likes this
Abdur Rehman January 28, 2025

Hi @Stefan Salzl @Bill Sheboy

Thank you so much for your continued support!

Yes, I did try your suggestions. Sending an integer as an argument inside .plusYears() works fine for me, and the object updates as expected. However, the smart value still isn't working as intended. I've also tried the code you recommended, but unfortunately, it resulted in the following error.


Jira SM.png

I truly appreciate your time and effort in helping me troubleshoot this, and I’m grateful for all your assistance.

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.
January 29, 2025

Please post images of your complete, updated rule and of the Edit Object action.  Those may help to see the current context.  Thanks!

 

And as a tip: when writing diagnostic values to the audit log, add clarifying text to make it easier to compare to the rule later.  For example:

here is my field: {{issue.myField}}

 

Like # people like this
Abdur Rehman January 29, 2025

Hi @Bill Sheboy 

Thank you for your suggestion, I will keep that in mind from now on. 

Below are the images of complete rule and Audit log as advised. 

 Jira SM.pngJira SM1.png

What I am trying to achieve is to add Review Frequency (integer) to Last Periodic Review Date (Date) and save it in attribute Next Periodic Review Date (Date) of the same object. However,

{{object.Last Periodic Review Date.plusYears(object.Review Frequency.asNumber).format("MM/dd/yyyy")}} 

for Edit object attribute function is returning Null.

Thank you again for your continuous support. 

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.
January 30, 2025

As that field is an integer, the asNumber function should not be needed for this to work.  Let's confirm that attribute is correctly interpreted as an integer (number) by the rule...

Please add a write to the audit log with this and then retest:

is Review Frequency a number: {{object.Review Frequency.isNumeric()}}

That should return true or false.

 

If that is true, then write this to the log:

Review Frequency plus 1: {{object.Review Frequency.plus(1)}}

That will confirm if the value is in fact a number, and not just numbers in a text value.

 

Like # people like this
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 30, 2025

Hi @Abdur Rehman 

I couldn´t get it running neither simply using the integer nor using the smartValue with .asNumber.

I could just do it with adding an additional step in between that stores the value of the integer attribute to a variable and then using the attributes value (which is always stored as string) together with the .asNumber method to caluate the new date (see screenshots).

 

the variable for frequency

image.png

 

using the variable with asNumber in the edit object action:

image.png

 

audit log:

image.png

 

Please let us know if this works for you.

 

Best
Stefan

Like # people like this
Abdur Rehman January 30, 2025

Hi @Stefan Salzl 

It worked perfectly for me as well. Thanks a lot for your help and the solution — I really appreciate it!

@Bill Sheboy  I also want to thank you for your time and effort.

I’ve learned something new through this, and it’s all thanks to the community!

Regards

Abdur

Like Bill Sheboy likes this
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 31, 2025

hi @Abdur Rehman 

greate to know you got that working. Thanks for all the information you provided.

Please consider to hit the "Accept answer" button in order to mark this post as solved.

Best
Stefan

Like Abdur Rehman likes this
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.
January 31, 2025

Thanks for checking that, @Stefan Salzl 

This apparently shows the object's attribute is similar to other rule smart values which are loaded just-in-time by additional REST API calls.  (e.g., {{issue.subtasks}}, smart values from marketplace apps, etc.) 

Because of that, there was a timing problem where the value was not available fast enough to be added as the parameter to the plusYears() function call (and so passing null instead).

Like # people like this
2 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.
January 24, 2025

Hi @Abdur Rehman -- Welcome to the Atlassian Community!

When using the Lookup Objects action, that loads the results in this smart value:

{{lookupObjects}}

Followed by the attributes needed.  Did you intend to use the results of the lookup in one of the later rule steps, such as the plusYears() function call?

Kind regards,
Bill

Abdur Rehman January 27, 2025

Hi @Bill Sheboy

Yes, that is right. "Next periodic review date" is also an attribute of the same lookup object. I simply want to add "review frequency" to "last periodic review date" to calculate "Next periodic review date". These are all the attributes of same lookup object. 

 

Suggest an answer

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

Atlassian Community Events