So if I use the function below and hardcode a number, it works. But if I pass in a variable, it does not work.
Does plusdays not accept variables? If it does, what am I doing wrong?
{{triggerissue.duedate.plusdays({{triggerissue.recurrent days}})}}
I couldn't accept MA's answer because it was a comment under an existing answer so I'm reposting it here:
I found a key piece of information today that has resolved the calculation of the plusDays and plusBusinessDays function whilst passing in a variable. Apparently there's an "old" syntax you can use. Rather than {{issues.field.plusBusinessDays(yourVariable|numeric field)}} you can use the following:
{{#issue.field}}func=plusBusinessDays({{yourVariable|numeric field}}){{/}}
Notes:
replace field in issue.field with the date field in Jira that you want to add days to.
replace yourVariable|numeric field with either a smart value variable or a field storing a number
using this syntax worked for me!
source of information/inspiration was found here - https://codebarrel.atlassian.net/browse/AUT-1791
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Amazing it worked like a charm to increase due date by a variable. Wasted a lot of time for simple issues. JIRA smart value sucks.
{{#issue.dueDate}}func=plusBusinessDays({{varDay}}) {{/}}
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's a crime that we have to resort to this hack - but thank you for posting it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey, I found a simpler solution that worked for me. Make sure the variable is a number before performing the operation:
{{triggerissue.duedate.plusdays({{variable.asNumber}})}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello dear Community! Yup, my joy is the result of the contribution that @Leonardo Oliveira made, which solved a section of my automation process.
I simply wanted to add a resource that worked in my case.
The effective smartvalue ended up being:
{{issue.Start Date.plusdays(DiferenciaDias.asNumber)}} , where the variable "DiferenciaDias" was correctly invoked as it wasn´t enclosed in "{{}}".
Again, thanks for your contribution Leonardo.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Mariano, I'm glad it was helpful. Have a great day! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I read online that that's just the way it is. IIt just does not accept variables.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are they planning to add this, I also need this functionality. Maybe you found some workarounds? Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would like this updated too. I am struggling to see how you will use this automation if you need to use hard coded values in date.plus[unit] functionality.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had to use the variable in the if clause instead... so if <somenumber> = "weekly" then add 7 days a date field, etc. But that may not work for everyone. They need to fix it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @JJ that makes sense, but the scenario that I am looking at requires that I add the values of two fields together and this would give me the number of business days that I need to adjust the date by. I'm not hopeful it will be resolved quickly as the issue that Atlassian has raised for this has been dormant for a couple of years and is sitting unassigned. :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@JJ have it working after all. You don't need double curly brackets in argument.
{{issue.Planned start date.plusHours(issue.Duration (hours))}} works perfectly fine in my case. Please try this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Marius Kymantas - tried your suggestion - thanks.
It didn't work for me.
I don't have exactly the same fields as you do, so I couldn't use duration in my Jira instance, but it looks like that you are essentially passing a numeric that is stored in a field, so I figured that if I removed the curly brackets and passed in a field on the issue that resolves to a numeric to the {{issue,start date.plushours()}} function, I should be in the same ballpark. The result of this approach is that I didn't get an error, but I also didn't get a result (an empty string I assume, since I am outputing my test results to issue.description)
Also, where did you find the information for using <issue.Duration (hours)>. I can't find this syntax anywhere in the Jira automation or smart values doco that's available on the web? I assume this converts the duration value (probably stored in seconds) to hours. All the other objects/fields seem to use a syntax along the lines of issues.duration.hours. e.g. https://support.atlassian.com/jira-software-cloud/docs/use-smart-values-to-manipulate-and-format-dates/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@MA "Duration (hours)" is just custom Jira field name I created (type "number"). I wanted the field name to indicate that people would understand that this number is treated as hour in automation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Marius Kymantas Well didn't I just read too much into it then :)
Thanks for the clarification
I guess I have found the automation and smart value documentation a little brief to date, and most of the bits that I have worked out have been by a process of elimination.
I have seen that there has been a request to Atlassian for more comprehensive documentation along the lines of standard functional or language APIs that detail descriptions, types, values, functions and more diverse and robust examples etc. I'd like to add my voice to this request.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found a key piece of information today that has resolved the calculation of the plusDays and plusBusinessDays function whilst passing in a variable. Apparently there's an "old" syntax you can use. Rather than {{issues.field.plusBusinessDays(yourVariable|numeric field)}} you can use the following:
{{#issue.field}}func=plusBusinessDays({{yourVariable|numeric field}}){{/}}
Notes:
replace field in issue.field with the date field in Jira that you want to add days to.
replace yourVariable|numeric field with either a smart value variable or a field storing a number
using this syntax worked for me!
source of information/inspiration was found here - https://codebarrel.atlassian.net/browse/AUT-1791
HTH
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.
Hi,
PlusDays function expects a number value I suppose.
What is the output of {{triggerissue.recurrent days}} ? If that gets a number value, try
{{triggerissue.duedate.plusDays({{triggerissue.recurrent days}})}} or
{{triggerissue.duedate.plusDays({{issue.customfieldId}})}} where customfieldId is the field id of triggerissue.recurrent days
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.