Forums

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

Is it possible to use nested Smart Values?

Sean Dooley
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 3, 2020

I can't seem to find a way to use a variable inside a smart value. For example:

{{ now.withMinute( {{originalMinutes}} ) }}

 

...where {{originalMinutes}} is declared earlier in the automation as a math function:

{{#=}} {{issue.customfield_10030.toStartOfDay.diff(issue.customfield_10030).minutes}} - ({{originalHours}} * 60) {{/}}

 

I'm trying to update a datetime value to a new date, while retaining the time. So far I have all the pieces, but when I go to put them together, they require nesting of some sort, which appears unsupported.

 

One way around this would be if I could pull the hour, minute, and second attributes directly from the original datetime, but that also appears unsupported (or at least poorly documented).

3 answers

1 accepted

3 votes
Answer accepted
Ignas Selvestravičius
Contributor
June 8, 2023

Atlassian shared with me the solution.

So it is possible to do nesting with variables. Here is how:

  1. Create a variable varTemp to hold the value "originalMinutes"
  2. Then use the variable like this:

    {{now.withMinute(varTemp)}}

    Note that you don't need the braces inside the brackets.

 

Below is my automation which might give you a better understanding. My case: add business days to get Due date to create issues every month with new Due dates.

image.pngimage.png

Knust_ Johannes
Contributor
December 30, 2024

lovly! Thanks for sharing. This also works in complex regex like: 
{{lookupIssues.summary.match("^(?:CR|RW)HighestCycleNumber-(\\d{3})").asNumber.max}}

Like # people like this
Eric Pratt
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 10, 2025

@Knust_ Johannes how do you get this to work with regex? Can you provide an example?

 

I tried creating a variable with the name regex and the value of:

"entryId=[^&]+&", "entryId={{userInputs.id}}&"

 

and the try to call it later like so:

{{webResponse.body.body.atlas_doc_format.value.replaceAll(regex).jsonEncode}}

 

But it just returns empty. I verified it works if I hard code the regex into the second call. 

Knust_ Johannes
Contributor
March 18, 2025

hi @Eric Pratt _Jira Admin_

it seems jira changed something; nevertheless here is my scenario and solution to it.

my requirement was a jira issue with title t should be able to automate with a change request or reword and marked in a new ticket t+1 with CR02-000 (first digits) or rework RW01-001 (last three digits) increase +1

therefore from t to t+1 its easy you know its the second ticket so either its CR +1 = 2 or its RW therefore 01 stays and the sum of 000 + 1 = 001.

The magic starts with reading from ticket t how many linked tickets t+x exists; read the last and calculate based on the logic + 1.

I found out that I can do things like this: 
(easy)
var: HighestCycleNumber =  {{lookupIssues.summary.match("^(?:CR|RW)(\\d+)-").asNumber.max}}

(advanced - a two step process!)
var: TempRWCycleNumber = {{lookupIssues.summary.match("^(?:CR|RW)(\\d{2}-\\d{3})").replace("-", "").asNumber.max}}

var: RWCycleNumber = {{TempRWCycleNumber.right(3)}}

and than some if else explosion (yes I used pen and paper to get my scenarios)

Screenshot 2025-03-18 at 20.40.08.png


When creating than the new ticket the title is in this first example:
RW0{{HighestCycleNumber}}-00{{RWCycleNumber.asNumber.plus(1)}} : {{triggerIssue.summary}}

Why so complex? 
Easy, when using regex Jira does not allow to keep leading 0's...
Therefore I had to identify the amount of leading 0's and made it work. 

hope that helps; it took me a while and AI could not figure that out either :P

0 votes
Darryl Lee
Community Champion
December 7, 2020

Don't you wish we could upvote Automation feature requests:

Possibility to nest smart values in Automation: 

https://codebarrel.atlassian.net/browse/AUT-2086

0 votes
John Funk
Community Champion
July 6, 2020

Hey Sean - Welcome to the Atlassian Community!

Take a look at this previous post:

https://community.atlassian.com/t5/Jira-Core-questions/Is-there-a-way-to-concatenate-or-nest-smart-values/qaq-p/1374187

Suggest an answer

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

Atlassian Community Events