Forums

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

Automation for a single select field

Dd
Contributor
August 20, 2024

Hi,

I defined a custom field called Week-of-the-Year which has 53 values to select one from ranging between 01 and 53.

I would like automation to set it based on the number of the current week: "{{now.format("w")}}"

How do I make that happen? How can I use smart values to set my Week-of-the-Year single select based on the actual week?

If I need to change the 01,02... to 1,2 - that can be done but I cannot use text field since it won't work for my dashboard.

Thanks

2 answers

1 accepted

0 votes
Answer accepted
Tessa Tuteleers
Community Champion
August 20, 2024

Hi @Dd , 

Yeah this is certainly possible, however, your select field values need to reflect exactly what the  format(w)  returns for this to work. 

To set your select field using automation with a variable, you will need to use the advanced field editting. 

{ "fields": {
"customfield_123456": { "value": "{{now.format("w")}}" }
}
}

You get the customfield_id by going to the custom field configuration and checking the URL. 

You can find some documentation about this here.

Cheers!

- Tessa

Tessa Tuteleers
Community Champion
August 20, 2024

And if you don't want to change your select list from "02" -> "2", you could use a leftPad function, then it would look something like this: 

{ "fields": {
"customfield_123456": { "value": "{{now.format("w").LeftPad(2,"0")}}" }
}
}

 

Test it out! 

Like Dd likes this
Dd
Contributor
August 20, 2024

Works like charm!

Thanks

 

Like Tessa Tuteleers likes this
Tessa Tuteleers
Community Champion
August 20, 2024

Good to hear it @Dd

0 votes
Kalyan Sattaluri
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 20, 2024

Hello @Dd 

You could use weekofyear to get the week #. like below...

{{now.weekofyear}} OR

{{updated.weekofyear}} etc.

Hope it helps. Thanks.

 

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