The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

2 votes
Answer accepted
Trudy P Claspill
Community Champion
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 P 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 P Claspill
Community Champion
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 P Claspill , somehow I overlooked it.

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

Like • Trudy P Claspill likes this
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events