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

2 votes
Answer accepted
Trudy 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 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 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 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
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events