Forums

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

Smart values in automation - formatting

Dd
Contributor
August 26, 2025

Hi,

I have a custom field - cycle which is a single list select,

It's values are the 2 last digit of a year and a sequential number (week number divided by 2).

For example, possible values:

  • 25-07
  • 26-15

I would like to use a manual trigger in automation that when I run it, a that cycle field gets populated by the last 2 digits of the current year and the week number padded to 2 digits (so I don't get 25-9 but rather 2509

What I do know is:

  • now.format("yy") - will probably give me the year's last 2 digits (is that correct)
  • {now.format("w").LeftPad(2,"0")}

How can I make the above happen?

  • Divide the week number by 2 rounded up
  • Set the value of cycle to be the concatenation of all.

The current automation:

Screenshot 2025-08-27 100024.png

Thanks

 

3 answers

2 votes
Duc Thang TRAN
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 26, 2025

Hello @Dd 

For Week divide by 2 

{{#=}}{{now.weekOfYearIso}} / 2 {{/}}

For year with 2 digits and exclude 0 for exemple 2009 

{{now.format("yy").replaceAll("^0","")}}

So combine 2 sections i think is 

{{#=}}{{now.weekOfYearIso}} / 2 {{/}} - {{now.format("yy").replaceAll("^0","")}}

Hope this can help :)

Dd
Contributor
August 27, 2025

I'll try. Thanks

Duc Thang TRAN
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 28, 2025

Something like that @Dd 
During the test, I'm using a date-time field  then get information: week number divided by 2, and the year in 2 digits.
In exemple : Jun 12, 2007, 2:00 AM
Then edit the Equipe (select list). You need to create all values as needed. Here is the config and audit log

2025-08-28 10_42_09-Rule builder - Automation - Admin Jira - Test - Jira — Mozilla Firefox.png

2 votes
Pedro Olmo
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 26, 2025

Hello @Dd ,

 

I would, for example, try splitting that field as in the screenshots I attached from the issue.key, so you can keep the first value and the last one. With those two variable values, you can then combine them into one.

Captura de pantalla 2025-08-26 103948.png

 

Captura de pantalla 2025-08-26 104026.png

 

Edit field with two values:

Captura de pantalla 2025-08-26 104136.png

 

Regards

Dd
Contributor
August 27, 2025

I'll try - thanks

Like Pedro Olmo likes this
Pedro Olmo
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 28, 2025

Hello @Dd ,

 

Doesn’t it work for you with the split on the custom field? 
It should let you grab the first value before the “-” and the last one. With those two variables, you can then concatenate them into the field you need.

If you need anything else, just let me know here.

 

Regards

0 votes
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.
August 26, 2025

Hi @Dd 

For a question like this, context is important for the community to help.  Please post the following:

  • an image of your complete automation rule in a single image for continuity
  • images of any relevant actions / conditions / branches
  • an image of the audit log details showing the rule execution
  • explain what is not working as expected and why you believe that to be the case

Until we see those...

 

When you tried putting those expressions together, what did you observe happening?

 

You are asking how to build the value for a selection field, and so that likely needs to be built and stored in a Created Variable, and then use JSON to make the selection.  Doing it that way will allow incrementally building the result and checking progress...And, validating your assumptions.  (For example, you describe dividing the week by 2 and rounding down, and so should the value for 1 be week 00?)

Here is an example that will produce that value with date, text, and math functions, assuming the value of 00 for the week is acceptable.

{{now.format("yy")}}-{{now.format("w").asNumber.divide(2).format("00")}}

 

Kind regards,
Bill

Dd
Contributor
August 26, 2025

You are correct - I need to start from 1 (my bad). Is there a way to round up?

While waiting for a reply - I'll run the above and post all requested based on that (to be honest - it's a manual trigger and the smart values I tried were so far - I assume that is irrelevant)

Thanks

 

Dd
Contributor
August 27, 2025

Tried the above - go the following (I hate JSON)

Screenshot 2025-08-27 100125.png

I probably miss some bracket ...

 

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.
August 27, 2025

First for the error you see, there is an extra left-curly bracket in there.  As a tip, I recommend writing stuff like this in an external editor which shows pairing for parentheses, brackets, etc.

 

Next for the rounding: this cannot be done with the inline math, as that is using integer math because the week number is an integer...and thus loses the fractional part.

We can change that second part to use a long-format math expression with the ROUND function.

{{now.format("yy")}}-{{#=}}ROUND( {{now.format("w")}} / 2, 0 ){{/}}

But now we have a formatting problem.  The fix, as often is the case, is Created Variables.  That will also avoid any timing problems building the JSON.

  • action: create variable
    • name: varYear
    • smart value: {{now.format("yy")}}
  • action: create variable
    • name: varQuarter
    • smart value: {{#=}}ROUND( {{now.format("w")}} / 2, 0 ) {{/}}
  • action: create variable
    • name: varYearQuarter
    • smartValue: {{varYear}}-{{varQuarter.asNumber.format("00")}}
  • then use {{varYearQuarter}} in the JSON

 

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.
August 27, 2025

Sorry for all of the updates; there is something "glitching" when I posted that one.

Dd
Contributor
August 28, 2025

Applied, got the following error:

Screenshot 2025-08-28 102040.png

Dd
Contributor
August 28, 2025

We are close.

I added the LogAction steps and here is what I get:

Screenshot 2025-08-28 112101.png

The format is correct - it just won't accept it. Could it be the extra space between the dash (-) and 18?

I don't have spaces in the rule itself (when concatenating the 2 values, no space in between). The only thing I can think of is that week componenet generates that leading space:

{{#=}}ROUND( {{now.format("w")}} / 2, 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.
August 28, 2025

Thanks for those updates, @Dd 

Would you please show the details of your edit action, including the JSON expression?

I hypothesize it "thinks" you are trying to use the field option id rather than the value attribute.

Dd
Contributor
August 28, 2025

Sure

{
"fields": {
"customfield_10627": {
"value": "CurrentDevCycle"
}
}
}
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.
August 28, 2025

If your variable is named CurrentDevCyle, you need the double-curly brackets around that in the JSON to be recognized as the smart value:

{
"fields": {
"customfield_10627": {
"value": "{{CurrentDevCycle}}"
}
}
}

 

Dd
Contributor
August 28, 2025

Still getting the same error.

I have a feeling that the CurrentDevCycle is "25- 18" with a space between the dash (-) and the 18 and therefore an illegal value.

Is there a way to get rid of that?

In the meantime - I'll test that

 

Dd
Contributor
August 28, 2025

Confirmed!

I added the "25- 18" with the blank and it worked.

I can probably change the values but that would be giving up :-( 

Is there a way to get rid of the extra blank?

Dd
Contributor
August 28, 2025

omitting the dash: {{varYear}}{{varBiWeekly}}

Resulted in "25 18"

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.
August 28, 2025

Something is up...I just re-tested exactly what I posted above and it worked with no extra  / embedded spacing.  If you post images of each Create Variable action that will identify the cause.

 

And just to confirm, you are using Jira Cloud, correct?

Dd
Contributor
August 28, 2025

Yep - Jira Cloud

 

varYear: {{now.format("yy")}}

varBiWeekly:  {{#=}}ROUND( {{now.format("w")}} / 2, 0 ) {{/}}

CurrentDevCycle: {{varYear}}-{{varBiWeekly}}

Dd
Contributor
August 29, 2025

It worked!

I removed all redundant blanks and it worked!

Was:: {{#=}}ROUND( {{now.format("w")}} / 2, 0 ) {{/}} 

Now: {{#=}}ROUND({{now.format("w")}}/2, 0){{/}}

I don't know which blanks made the change but it worked. Any idea?

BTW - where can I find documentation on all the different operations on smart values you performed?

BTW - what will happen when I get to Week 1 in 2026?

Thanks!

Like Bill Sheboy likes this
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.
August 29, 2025

Regarding the spaces...without seeing your actual rule actions, I cannot guess on the cause.  Even with the spaces inside of a math expression, those will be eliminated, as they were in my testing.  And so the extra space is likely from one of the other rule actions.

Finding "documentation" on the various smart value features...requires two things: when the docs mention links out to Java documentation, go read that also; and, always experiment with simple test rules to confirm the behavior.  Unfortunately, there are many errors in the docs and a test rule with a write to the audit log helps validate behavior.  For example...

For week 1 in 2026...you could quickly test that with a rule:

  • use a Scheduled trigger with no JQL
  • create a variable, such as varTestDate, with a value of 2026-01-01
  • convert that with toDate and use it in the expressions, written to the audit log
    • {{#=}}ROUND({{varTestDate.toDate.format("w")}}/2, 0){{/}}
  • run the rule, adjusting that first date to check the behavior in the log

 

Suggest an answer

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

Atlassian Community Events