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

Alex Degregori February 2, 2021

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.
February 2, 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.

Alex Degregori February 2, 2021

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.
February 2, 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.
February 2, 2021

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.
February 2, 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.
February 2, 2021

Bam. That did it. Try this:

{
    "fields": {
        "fixVersions" : [ {{#issue.customfield_10050}} { "name": "{{value}}" }{{^last}} , {{/}}{{/}} ]
    }
}
Like ā€¢ Bill Sheboy likes this
Alex Degregori February 3, 2021

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
Alex Degregori February 3, 2021

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.
February 2, 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