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 help
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
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Abdur Rehman please look again at the suggestion from @Stefan Salzl ...
You have added unnecessary curly-brackets inside the function call for plusYears().
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
I truly appreciate your time and effort in helping me troubleshoot this, and I’m grateful for all your assistance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
using the variable with asNumber in the edit object action:
audit log:
Please let us know if this works for you.
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.