Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

plusdays function not working when I pass in a variable

 

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}})}}

 

recurrentdays.gif

3 answers

1 accepted

3 votes
Answer accepted

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 saved my day!

Glad this sorted it out for you!

Like Nicolas Degardin likes this

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}}) {{/}}

Like # people like this

Thank you!! You saved my day too!!

Like # people like this

Happy to have helped :)

I read online that that's just the way it is. IIt just does not accept variables.

Are they planning to add this, I also need this functionality. Maybe you found some workarounds? Thanks

Like MA likes this

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.

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.

Like MA likes this

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.  :(

@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.

Like # people like this

@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/

@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. 

@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.

 

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

Like # people like this

thanks @MA for the workaround :)

0 votes
Niranjan
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.
Oct 07, 2020 • edited

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

The outcome of triggerissue.recurrent days is a double. So that's definitely working.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events