Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Call Function with argument in Jira Automation

Jakob Wendt August 18, 2020

I am stuck at a problem that probably shouldn't be one.

 

I want to calculate a future date with Jira automation. The date is x-hours from a given timestamp, where x is a number of hours provided by the Issue.

 

To calculate the future date, I tried:

{{now.plusHours({{hours}})}}

and


{{now.plusHours(hours)}}

 

because I wasn't 100% certain about the correct syntax.

The first just returns nothing if I try to log the value, the latter just throws the error

Failed to get value for now.plusHours({{hours: {{now.plusHours({{hours}})}}

 

To isolate the Issue, I already tried to set hours to a fixed value (e.g. 300) with no success.

Also, I tried the aforementioned syntax directly with a fixed value

{{now.plusHours(300)}}  

which works just fine.

 

So I guess the core-question is: How to reference Smart-Values within Functions?

 

What am I missing? 

2 answers

1 accepted

1 vote
Answer accepted
Sherry Goyal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 18, 2020

@Jakob Wendt  

You can use something like

{{now.plusHours(issue.hours | 1)}}

where 1 is default value if issue.hours does not exists. Hopefully this answers your query.

 

Cheers
Sherry 

Jakob Wendt August 24, 2020

This worked, thanks so much for your answer!

0 votes
Florian
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.
August 18, 2020

Try the fully qualified field name so instead 

{{now.plusHours(hours)}}

use  

{{now.plusHours(issue.hours)}}

If this does not work try

{{now.plusHours(issue.customfield_xxxxx)}}

Where xxxxx is the field’s numerical ID.  

Jakob Wendt August 18, 2020

Okay, that works kind of the way I would expect.

But what, If the value hours wasn't supplied directly by the user but instead created within the automation script?

Florian
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.
August 19, 2020

When you modify field within an automaton script and want to refer to that value later within the same script you have to reload the issue. There is a workflow action called „refresh issue“ or something like that. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events