Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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 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 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...

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 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 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

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
Community showcase
Published in Confluence

Introducing External Collaboration for Confluence

We’re excited to introduce external collaboration for Confluence, now available in early access. It is available to preview for Confluence Cloud Premium and Enterprise customers. (If you're not on ...

182 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you