Custom Field - User Picker - Set value

Girish Hippargi April 23, 2024

I have a custom field called "tester". The custom field is single user type i.e. the checkbox "Restrict to Single User" is set.  I want to update value of this field with value of assignee upon a transition.

I have used "Project Setting" -> Automation for this.  In this automation, I have used "When: Issue Transitioned" Then "Edit: Issue Fields". In the edit issue "Advanced Option" in additional fields, I have used this JSON

{
"fields": {
"Tester": {{initiator.accountId.asJsonObject("id")}}
}
}

On execution, it is giving error

"Error editing issues

ATL-3646 (data was not an array (customfield_11965))"
What is the issue and How to resolve this?

1 answer

2 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 23, 2024

Hello @Girish Hippargi 

You don't need to use Advanced Options and JSON for that.

If you want to copy the value of one User Picker (single) field (like Assignee) to another User Picker (single) field you can do that with the Copy option in the Edit action.

Screenshot 2024-04-23 at 10.57.33 AM.png

 

That changes the text in the field as shown below. Click on that text and you get a pop-up to select the issue and the field from which you want to copy the value.

Screenshot 2024-04-23 at 10.58.10 AM.png

Change the Field to copy value from to Assignee.

Screenshot 2024-04-23 at 10.58.24 AM.png

Screenshot 2024-04-23 at 11.01.22 AM.png

 

Girish Hippargi April 23, 2024

Thanks for the response @Trudy Claspill But the problem is that I want to copy assignee value into custom single user picker field. But the custom field is not displayed in the "Choose field to set" dropdown

Screenshot 2024-04-24 115450.png

 

That is why I had no option but to use the "Additional Fields" advance option and json.

Hope my problem is clearly understood now. Thanks.

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 24, 2024

Are you working on an Automation that will apply to a Company Managed project or a Team Managed project?

Can you show us the custom field configuration, so that we can confirm the field name and type?

 

There is an example of setting a single user picker field (Assignee) in this document:

https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/

The example looks like this:

{ "fields": { 
"assignee": {
"id": "{{initiator.accountId}}"
}
}
}

In your case if the field you want to set is Tester, and you want to set it to the same person that is currently in the Assignee field, then I believe the correct code would be:

{ "fields": { 
"Tester": {
"id": "{{Assignee.accountId}}"
}
}
}

 

Girish Hippargi April 25, 2024

Its a Team-Managed Project. Automation will apply to a Team Managed project.

Field "Tester" Details as screenshot:

Screenshot 2024-04-25 154322.png

I had referred to the documentation and used

{ "fields": {
"assignee": {
"id": "{{initiator.accountId}}"
}
}
}

Was still getting the same error "data was not an array"

I made the change suggested:

{ "fields": {
"Tester": {
"id": "{{Assignee.accountId}}"
}

Still got the same error:

Error editing issues ATL-498 (data was not an array (customfield_11965))

Please suggest.

Thanks.

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 25, 2024

Hello,

I provided the answer without testing it, just referencing the documentation. When I tested it myself in a Team Managed project I got the same error your did.

I think I made an error in the code - I left out the issue prefix in the smart value.

{ "fields": { 
"Tester": {
"id": "{{issue.Assignee.accountId}}"
}
}
}

But even after I corrected it in my own system I got the same error that you did data was not an array.

I've tried some variations but keep getting the same error.

The same methodology works fine in a Company Managed project.

I have not yet found any references that this should be done differently in a Team Managed project.

I'm going to do something that I really don't like to do often, and tag another community member that has demonstrated a high level of expertise in this specific area (Automation). @Bill Sheboy can you assist with this?

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.
April 25, 2024

Hi @Girish Hippargi and @Trudy Claspill 

The People-type field in Team-managed project (TMP) have some challenges in rules...and this appears to be one I did not know:

They appear to be multiple-select behind the scenes and that checkbox for "Restrict to single user" only impacts entry on the issue views.  I confirmed this by looking at the data with this how-to article to see the stored structure of the issue data: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

To solve your need, please use the JSON format for a multiple-select field with the custom field ID for your field, and only supply one value in the array:

{
"fields": {
"customfield_12345": [
{ "id": "{{issue.assignee.accountId}}" }
]
}
}

I tested to confirm it works.

Kind regards,
Bill

Like # people like this
Girish Hippargi April 26, 2024

Thank You @Bill Sheboy 

The solution worked.

How can we have the atlassian documentation updated ? or the issue fixed?

 

Thanks @Trudy Claspill for your help.

Like Bill Sheboy likes this
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.
April 26, 2024

Awesome; I am glad to learn that helped!

Regarding documentation, I recommend posting feedback on the documentation pages and from the automation rule editor.  Many of the differences for TMP versus CMP are subtle; some are not ;^)  Giving feedback on what we find will help Atlassian understand the impact to customers and so guide improvements.

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