Hi there,
I have checked many posts here and seems to write my smart value correct however, output is blank.
My first variable: {{vicDay}} is defined as
{{now.format("YYYY")}}-05-25
My second variable: {{vicDateDay}} is defined as
{{vicDay.toDate.DayOfWeek.minus(1)}}
Both variables return values in the log: as 2024-05-25 and 4 respectively
Now, I use the numeric value in my third variable: {{vicDayFinal}} defined as
{{vicDay.toDate.minusDays(vicDateDay)}}.
When I type in numeric value in the formula {{vicDay.toDate.minusDays(4)}} it returns 2024-05-20 as expected, when I use vicDateDay variable name then it returns null. The log shows that vicDateDay is Numeric.
Here is the log:
vicDay - 2024-05-25, vicDateDay - 4, vicDayFinal - , isNumeric - true, isAlpha - false
Anybody please help me on this.
Thanking in advance.
Hi @Anna
What problem are you trying to solve by doing this? Knowing that may help the community to offer alternative solutions.
Until we know that...
Created Variables are text. When you want to use them in a function such as minusDays() they must be converted with asNumber:
{{vicDay.toDate.minusDays(vicDateDay.asNumber)}}
Kind regards,
Bill
Hi Bill, I calculate Victoria Date as a variable. I tried asNumber function and the output is still null. Log is below
I need to exclude my scheduled trigger run on holidays, this is the objective of exercise.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please post an image of your complete rule (in one image) and an image of the audit log details showing the rule execution. Those will provide context to help explain what you are observing. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Where you write the smart value expressions to the audit log, try writing the variables instead: {{vicDay}}, {{vicDateDay}}, and {{vicDayFinal}}
That will help confirm the variables contain what you expect.
Also, smart values are case-sensitive, and I believe the attribute DayOfWeek should be dayOfWeek: https://confluence.atlassian.com/automation/jira-smart-values-date-and-time-993924864.html#Jirasmartvaluesdateandtime-attributesAttributes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Bill, thanks a lot for your reply. I have fixed the case to dayOfWeek and always check each calculation in log when move to the next step. I added variable where argument is explicitly defined as number and it works:
{{vicDay.toDate.minusDays(vicDateDay.asNumber)}} - returns null
{{vicDay.toDate.minusDays(4)}} - returns 2024-05-20 as expected
so the issue is caused by variable argument.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I wonder...please try setting vicDateDay to 4 explicitly with no calculation.
If that does not work, it suggests that the minusDays() function for Jira Data Center cannot take a variable as a parameter. I looked and did not find this listed as a defect in the public backlog
A longer version to try would be putting it all together for final date:
{{vicDay.toDate.minusDays(vicDay.toDate.dayOfWeek.minus(1))}}
Or, brute force the value with another variable using a math expression, and then convert that to a date:
{{now.format("YYYY")}}-05-{{vicDateDay.asNumber.multiply(-1).plus(25).format("##")}}
How that works:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hooray! it worked
Bill, thanks a lot for your great suggestion, i used the line below as you suggested and it worked. I can't believe it, spent 2 days on it with hundreds of combinations!!!
{{vicDay.toDate.minusDays(vicDay.toDate.dayOfWeek.minus(1)).jiraDate}}.
I will mark this as answered
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome; I am glad you have it working!
There are other open defects for Jira Data Center's use of created variables in functions, but not this specific case with minusDays(). You may want to ask your Jira Site Admin to submit a defect so Atlassian knows about it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.
Register today!Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.