Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

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

Automatically set a multi-choice field value based on text

Gergana_Damyanova
Contributor
May 12, 2023

I'm doing an automation that should set a the value of a custom field based on some text that is dynamically extracted.

I can't get my head around how to update the value of the field.
The key of the project is extracted correctly and is present in the multi-choice options, but I don't know how to select the option that matches the text from the smart value.

Any ideas?

Screenshot 2023-05-12 at 16.51.02.png

 

This is how I do the update:
{
"fields": {
"customfield_10453": {
"value": "{{issueProject}}"
}
}
}

The above doesn't work, however with a hardcoded value it works
{
"fields": {
"customfield_10453": {
"value": "MC"
}
}
}

1 answer

1 accepted

2 votes
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 12, 2023

Hello @Gergana_Damyanova 

Is the custom field one where you can select only one value or were you can select multiple values?

Have you confirmed that the smart value {{issueProject}} actual contains MC by using the Log action to print the smart value in the rule Audit Log?

Gergana_Damyanova
Contributor
May 12, 2023

Hey @Trudy Claspill ,

Only one value can be selected for the custom field.

The issueProject value is ok, and passes the right value that is one of the options in the multi-choice. You helped me with this just the other day:  {{issue.key.substringBefore("-")}}

So using this, I'm able to extract the value I want, but for some reason the multi-choice field doesn't like it.

Here is a proof I have it in the multi-select:
Screenshot 2023-05-13 at 8.33.27.png

And here is what the Audit log says

Screenshot 2023-05-13 at 8.36.58.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 14, 2023

Please use a Log action to print the value of your variable in the Audit Log.

If TK111111-6 is the issue that is triggering the rule, and

If you are setting the variable to {{issue.key.substringBefore("-")}}, then

The variable is getting set to TK111111, and

TK111111 is not a valid value in the selection list for which you provided an image.

Like Gergana_Damyanova likes this
Gergana_Damyanova
Contributor
May 15, 2023

Oh man, such a silly mistake, this is embarrassing. 
I've put the issue number, not just the project key, thanks for pointing this out @Trudy Claspill , somehow I overlooked it.

Thanks again, I changed the option in the multi-choice and its working.

Like Trudy Claspill likes this

Suggest an answer

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

Atlassian Community Events