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:
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:
How can I make the above happen?
The current automation:
Thanks
Hi @Dd
For a question like this, context is important for the community to help. Please post the following:
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry for all of the updates; there is something "glitching" when I posted that one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We are close.
I added the LogAction steps and here is what I get:
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 ) {{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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}}"
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yep - Jira Cloud
varYear: {{now.format("yy")}}
varBiWeekly: {{#=}}ROUND( {{now.format("w")}} / 2, 0 ) {{/}}
CurrentDevCycle: {{varYear}}-{{varBiWeekly}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Edit field with two values:
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.