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,298,560
Community Members
 
Community Events
165
Community Groups

How to automate a multi-select user field in team-managed projects?

We use a team-managed project (NextGen) in JIRA.

Problem

I am trying to create an automation that edits newly created issues: I want certain fields to be copied from the parent epic. My automation works with default fields like assignee and labels because I am able to pick them in the dropdown menu when creating an automation. My user multi-select field is custom and therefore doesn't show up in the dropdown menu when editing an automation. I suppose, I have to use the advanced text box to make it all work the way I need it to.

What I've tried

I've tried searching forums and copy-pasting (and editing cutom field ID or name) code other users have suggested into my automation, but that didn't work. I've also tried reading through JIRA documentation and copy-pasting (and editing custom field ID or name) code from there, but this also didn't work.

The best result I've got is automation saying it worked OK but not actually editing the custom user field. Other times I would either get an error saying 'data was not an array (customfield_10059)' or 'Error while parsing additional fields. Not valid JSON.'

Any help would be greately appreciated, thank you!

3 answers

1 accepted

1 vote
Answer accepted
Simmo Atlassian Team Aug 23, 2021

Hi @Petr Sigaev

When you say that it is a multi user field and it isn't showing up, is that in the list of fields to edit for the Edit Issue action?

As far as I can see in the code we support multi user fields and it should be showing up. If you look at the JSON response as mentioned above, is the field type 

com.atlassian.jira.plugin.system.customfieldtypes:multiuserpicker

Cheers,

Simeon.

Hi! Thank you for your response. What I mean by multi-user custom fields not showing up in the automation dropdown menu is that they aren't there for team-managed projects. Let me provide you with an example.

photo_2021-09-02_16-15-16.jpg

I have a custom user field that supports selecting multiple users here. It's called MultiUserField (this is a test board).

However, when I try to make an automation with it, I can't find it in the Edit Issue dropdown menu as shown on the screenshot below.

photo_2021-09-02_16-16-18.jpg

I presume, I have to use the advanced text box to edit this field. I am not sure which line of code is needed to accomplish automatic editing of this field based on what's selected in the epic's MultiUserField.

Also, sorry for taking so long to reply to your message. I'm new here and I assumed I will receive a bell notification in JIRA. I didn't realise I have to visit the forums to see I have replies on my question, I just assumed there was no activity and got lost in my day-to-day tasks.

Simmo Atlassian Team Sep 05, 2021

Hi @pe ,

So they should be there however, custom fields for team managed projects are specific to that project. So it depends on where you're configuring your rule.

If you're in another project it won't show up. It will only show up in that project and global / multi project rules.

If that isn't the case, please raise a support ticket so we can look into it.

Cheers,

Simeon.

@Simmo thanks! I will raise a support ticket. I am configuring it inside the project, it is a local rule.

Simmo Atlassian Team Sep 09, 2021

Hi @Petr Sigaev

Is your field a cascading select?

@Simmo my field is a «People» field with «Restrict to a single user» option disabled:

photo_2021-09-10_11-08-17.jpg

Simmo Atlassian Team Sep 12, 2021

Hi @Petr Sigaev,

My apologies mate. I'd forgotten that team managed projects had introduced the People field, which we don't currently support in the UI.

We should be able to get the JSON going here. The underlying field structure is a list/array.

I just spent a bit of time on my dev instance figuring out a smart value for you that will work. My People field is called "ASB People CF" on both my epic and story issues:

{
"fields": {
"ASB People CF": {{issue.epic.ASB People CF.accountId.asJsonObject("accountId").asJsonArray}}
}
}

 Now, this smart value will copy across one hierarchy level. That is Epic -> Story/Task.

If you wanted to do Story/Task -> Sub task, change "epic" in the smart value to "parent".

Let me know how you go, but this should work, its just worked for me :) 

Apologies again for taking so long to get my head around what was going on!

Like Petr Sigaev likes this

@Simmo Thank you so much! Your JSON worked, brilliant!

Simmo Atlassian Team Sep 13, 2021

Hi @Petr Sigaev,

No worries mate! Glad we got there in the end. I do apologise for taking so long to realise what was going on. Glad it works!

Have a good one.

Cheers,

Simmo.

Like Petr Sigaev likes this
0 votes

Hello @Petr Sigaev 

If you don't mind using another solution, the add-on Elements Copy & Sync lets you do just that.

I'm the Product Manager of the app, and when creating an issue from an Epic, you can just configure which users you want added to any custom user picker. It looks like this : 

select-multi-users.png

With this simple configuration, my two users are automatically set in my custom field "TEST User Multi" when the issue is created.

I hope this help. Don't hesitate to contact our support team for any additional information.

Kind regards,

Julien

Hi!

Thank you for your suggestion.

If all else fails, I will definitely give your plug-in a try. Otherwise, I'd like to stick to built-in tools and not make another plug-in request.

I will, however, keep your suggestion in mind!

I understand perfectly. :)

Like Petr Sigaev likes this
0 votes

Hi @Petr Sigaev 

You have to use valid JSON to update the field. Try this.

{
"fields": {
"environment": "Thanks for raising {{issue.key}}.",
"labels": [
"bugfix",
"blitz_test"
],
"customfield_10149": [
{"value": "Option 1"},
{"value": "Option 3"}
]
}
}

If you are not sure about the valid JSON format then take a look at how JSON response looks like for an existing issue with those fields filled in using this end point.

JIRAURL/rest/api/3/issue/sd-26

For complete reference this page is very helpful: https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/

I hope it helps.

Ravi

Hi @Petr Sigaev -- Welcome to the Atlassian Community!

Adding to what @Ravi Sagar _Sparxsys_ suggests, here are a couple of other references to help:

Best regards,
Bill

The code you have suggested successfully edits the labels field and adds specified labels. However, I am still uncertain as to how to edit this code for the custom user field so that it looks up a field in the Epic and edits itself accordingly.

For example, Epic has 3 people in the custom user field: Mark, John, Anna. I want the automation to fill in the custom user field for a child task so that it matches the parent Epic issue. Meaning: Mark, John and Anna are automatically added to the custom user field of the child task.

I can't tell it to always fill in Mark, John and Anna because every Epic has different people attached to it.

Also, sorry for taking so long to reply to your message. I'm new here and I assumed I will receive a bell notification in JIRA. I didn't realise I have to visit the forums to see I have replies on my question, I just assumed there was no activity and got lost in my day-to-day tasks.

Running automation with this code returns no errors, but the field I want edited remains empty (MultiUserField).

{
"fields": {
"environment": "Thanks for raising {{issue.key}}.",
"labels": [
"bugfix",
"blitz_test"
],
"MultiUserField": [
{"value": "{[issue.parent.epic.MultiUserField.value}}"}
]
}
}

I've tried experimenting a little bit. I simply don't get it. I took chunks of code from the official documentation and implemented them into the preset you've provided just to see if they'll work, but I get errors and no fields are getting updated.

{
"fields": {
"environment": "Thanks for raising {{issue.key}}.",
"labels": [
{"value": "{{issue.parent.labels.asJsonStringArray}}"}
],
"MultiUserField": [
{"value": "{{initiator.accountId}}"}
]
}
}
Error editing issues
TUX-26 (Specify an string at index 0 for labels (labels))

I spent another hour reading through documentation and trying different snippets of code but no luck so far still.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Team-managed projects

Find issues faster in your team-managed board and backlog

Hi Jira Community! I’m Mark, a product manager working on Jira Software. Today, I’m happy to announce that we’re launching custom filters for team-managed projects. If you’ve used the quick filters...

3,870 views 20 21
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