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

Jira Automation: Can't use the result of a math expression to calculate a date

Emre Toptancı _OBSS_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 5, 2023

I am using Jira Automation on Jira DC 9.3.

What I am trying to do is to use the result of a math round function as a parameter of plusDays() function to set the duedate field.

(Below, I am using the value 13.2 for brevity. Actually, that value will come from another smart value, from the json of a previous REST call action.)

I tried this. This one works:

{{now.plusHours(round(13.2, 0))}}

But since the value from the REST call json is a string, I need to add an asNumber function like this:

{{now.plusHours(round({{asNumber}}13.2, 0))}}

When the rule runs, I get this error:

Error rendering smart-values when executing this rule:
Failed to get value for now.plusHours(round({{asNumber: {{now.plusHours(round({{asNumber}}13.2, 0))}}

Then I presumed this was caused by the round function not being enclosed in math expression tags so I tried this:

{{now.plusHours({{#=}}round({{asNumber}}13.2, 0){{/}})}}

This time I can't even publish the rule. I get the following error message while trying to publish:

Error parsing template: Mismatched start/end tags: null != in template ....

The one below saves and executes successfully but of course, it processes the now.PlusDays() function as text and doesn't run it. It just prints it.

now.plusHours({{#=}}round({{asNumber}}13.2, 0){{/}})

I hope someone can enlighten me about this.

Thank you

EmreT

 

 

1 answer

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 6, 2023

Hi Emre,

You need to setup a variable and then use the value of the variable. See this other post that will guide you through that. 

https://community.atlassian.com/t5/Automation-questions/Automate-quot-Target-Date-quot-field-when-ticket-is-moved-to/qaq-p/2251838

Emre Toptancı _OBSS_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 6, 2023

Hello @John Funk ,

We did this on the cloud platform just as you said, with a variable. But there is no Create Variable action on Jira DC.

Is there a workaround?

EmreT

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 6, 2023

Oh - not sure then as I don't have a DC version. @Bill Sheboy  - any thoughts? 

Bill Sheboy
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.
February 6, 2023

Hi @Emre Toptancı _OBSS_ and @John Funk 

I noticed you have some extra curly brackets in the expressions...once inside of the brackets the other ones are not needed.  For example:

{{now.plusHours(someVariable.asNumber)}}

Please note that I assumed use of a variable, and so converted from text to number type.

Next, round() has a few different syntaxes, such as {{issue.someField.round}} or {{#=}}round({{issue.someField,2){{/}}

If neither of those things help, please consider posting an image of your rule, including the details where the round() is occurring.  Those may provide some context for the symptom you are observing.  Thanks!

Kind regards,
Bill

Like John Funk likes this
Emre Toptancı _OBSS_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 6, 2023

Hello @Bill Sheboy ,

Below is the complete smart value that we are trying to use with Edit Issue action to update the duedate field.

{{now.plusDays({{#=}}round({{asNumber}}{{webhookResponse.body.table.body.rows.valueColumns.value.get(0)}}, 0){{/}})}}

As you can see, we are trying to round some value from the json result of an earlier Send Web Request action and add it to now to create a new duedate value.

It is worth emphasizing once again that we are on Jira DC 9.3 so there is no Create Variable action to use.

Thanks.

EmreT

Bill Sheboy
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.
February 6, 2023

Thanks for that information.  Perhaps trying using chained functions instead:

{{now.plusDays(webhookResponse.body.table.body.rows.valueColumns.value.get(0).asNumber.round)}}

Emre Toptancı _OBSS_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 7, 2023

Nope, doesn't work.

This one returns a value:

{{webhookResponse.body.table.body.rows.valueColumns.value.get(0)}}

But when you chain an "asNumber", it returns empty:

{{webhookResponse.body.table.body.rows.valueColumns.value.get(0).asNumber}}

 

You know what? I tried the same thing with original estimate field. The smart value below works for original estimate:

{{#=}}round({{asNumber}}{{webhookResponse.body.table.body.rows.valueColumns.value.get(0)}}, 0){{/}}d

It is clear that we can do asNumber and round without a problem. But when I try to send this value to plusDays function as a parameter (as shown below), it starts complaining about mismatched start/end tags and doesn't publish the rule.

{{now.plusDays({{#=}}round({{asNumber}}{{webhookResponse.body.table.body.rows.valueColumns.value.get(0)}}, 0){{/}})}}

 

Bill Sheboy
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.
February 7, 2023

That makes sense due to the embedded bracketing.  I suspect the reason the chained value does not work is typing related.  Perhaps consider sending that one to the support team and ask them why it does not work for the Server/Data Center version of automation rules.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events