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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,524
Community Members
 
Community Events
184
Community Groups

Getting error when trying to match a multiselect dropdown to Fix Versions

When trying to connect a custom multiselect dropdown field to the Fix version field via automation, I receive an error: Screen Shot 2021-02-02 at 5.46.34 PM.png

The Fix versions and the multiselect dropdown fields have the same values and are apart of the same project which is odd. I was able to automate these fields together when using a single field but needed to change the automation code to account for multi selections. 

Here is a screenshot of my automation set up: 

Screen Shot 2021-02-02 at 5.49.16 PM.pngScreen Shot 2021-02-02 at 5.50.04 PM.png

Any idea what the issue might be here? Thanks for any help in advance! šŸ™šŸ¼

2 answers

1 accepted

0 votes
Answer accepted
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 02, 2021

So, a couple of things.

1. If somebody selects multiple versions, this will probably break, because you'd potentially be trying to set the field to:

[{"name":"5.1","5.2","5.3"}]

2. I don't think you need the full {{/changelog.customfield_10050}}. {{/}} should do.

But anywho, I think what you need to do is:

{
    "fields": {
        "fixVersions" : [ {{#changelog.customfield_10050}} { "name": "{{fromString}}" }{{^last}} , {{/}} ]
    }
}

This code is untested. For debugging purposes, I always recommend adding an action to write to the Audit log. I would throw the whole "fixVersions..." line in there.

Thanks for the response, Darryl! Ya, I've been noticing some odd behavior when doing multiple field selections. 

When entering your code above, then attempting to publish changes, I got the following error: 

Error while parsing additional fields - Failed to close 'changelog.customfield_10050' tag

I think it has something to do with:  

{{^last}} , {{/}}

 When I removed the {{^last}} , it seemed to get rid of the error but still no dice with the automation. 

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 02, 2021

AUGH, I forgot an extra {{/}} closing tag that was messing me up for while, then I remembered this discussion:

https://community.atlassian.com/t5/Jira-Software-questions/Automation-How-to-print-changelog-for-Smart-values-like-quot/qaq-p/1444186

Which led to this bug:

https://codebarrel.atlassian.net/browse/AUT-2013

And this one:

https://jira.atlassian.com/browse/JRACLOUD-74953

In summary: {{changelog}} is kinda borked for multi-select fields. HOWEVER, I think {{fieldchange}} will work. I was at least able to get the values out. Let me see if I can tweak it to actually generate usable JSON...

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 02, 2021 • edited

Eh, I got close, but no cigar.

{{fieldchange.toString}}

Will return: 5.1,4.0

But as previously mentioned, your data needs to be in this format:

[{ "name": "5.1" },{ "name": "4.0" }]

So I tried what sounded like a perfect function:

{{fieldchange.toString.asJsonObjectArray("name")}}

But that gave me nothing. I thought it might be because toString was returning a string. Ok fine, so I tried:

{{fieldchange.to}}

That returned a more promising:

[10081, 10082]

But when I tried to feed it to asJsonObjectArray, still nothing. (Oh, and to @Nic Brough -Adaptavist-'s point, those are option values, not actual names of options, so even if I ended up with a proper JSON Object Array, the values would be all wrong.)

I'm getting the sneaking suspicion that fieldchange is not like other fields. :-{

To complete my futile journey, I tried one more horribly hacky thing:

{
"fields": {
"fixVersions": [ "name" : "{{fieldchange.toString.replaceAll("," , " \" \"name\" : \" ")}}"
}
}

The thought here is that I could use a text function to insert the necessary JSON tags and formatting. But... nope.

So, in summary.... I think I need to file a bug.

Also, how did I get this weird font? Huh.

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 02, 2021

Wait. I'm an idiot. We don't need to bother with fieldChange or changelog at all.

Because your field will already have been changed when the Automation is triggered, you should be able to use:

{{issue.customfield_10050}}

Maybe that will work with one of the aforementioned functions. Let me give that a whirl.

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 02, 2021

Bam. That did it. Try this:

{
    "fields": {
        "fixVersions" : [ {{#issue.customfield_10050}} { "name": "{{value}}" }{{^last}} , {{/}}{{/}} ]
    }
}
Like • Bill Sheboy likes this

Darryl! This is awesome. It works for me now. Thank you so much for the help and effort you put into this šŸ™šŸ¼

Gonna keep testing on my end but all seems to be good to go :) 

Like • Darryl Lee likes this

I am finalizing this automation flow and am running into a final issue which I posted here for anyone that might have a similar use case. 

Like • Darryl Lee likes this
0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 02, 2021

I think this is the problem:

"The Fix versions and the multiselect dropdown fields have the same values"

They do not.  They might have the same text in their names, but the fields contain different values.  A version field contains a version object, and a multiselect list contains one or more option objects.

To compare them, you'll need to code for looking at their names, not just the values.

Suggest an answer

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

Atlassian Community Events