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

Petr Sigaev August 23, 2021

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
Atlassian Team members are employees working across the company in a wide variety of roles.
August 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.

Petr Sigaev September 2, 2021

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
Atlassian Team members are employees working across the company in a wide variety of roles.
September 5, 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.

Petr Sigaev September 9, 2021

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

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 9, 2021

Hi @Petr Sigaev

Is your field a cascading select?

Petr Sigaev September 10, 2021

@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
Atlassian Team members are employees working across the company in a wide variety of roles.
September 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
Petr Sigaev September 13, 2021

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

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 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
Julien Peyrade @ Elements
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
August 25, 2021

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

Petr Sigaev September 2, 2021

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!

Julien Peyrade @ Elements
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
September 2, 2021

I understand perfectly. :)

Like Petr Sigaev likes this
0 votes
Ravi Sagar _Sparxsys_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2021

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

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2021

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

Petr Sigaev September 2, 2021

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.

Petr Sigaev September 2, 2021

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}}"}
]
}
}
Petr Sigaev September 2, 2021

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