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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

2 answers

1 accepted

0 votes
Answer accepted

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.

@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

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
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,044 views 8 28
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you