Automation for Jira: JSON Update People Custom Field

Paul Benati March 26, 2020

I need to update a People custom field via Automation for Jira.  Specifically, I want my custom field ("Work It" or "customfield_10150") to be set to a specific user, "service.center".

service.center is defined as:

{

}

 

Unfortunately, the Automation for Jira's Edit Issue action does not find my custom field, "Work It", in its dropdown.  Therefore, I need to leverage the Additional fields textbox (i.e., JSON).  In that textbox I've added:

{
    "fields": {
        "Work It" : { "id":"5e7a27d154fa650c3bc1b488" }
    }
}

When I run this automation I get the following error:

Edit issue
    Error editing issues
    SERVICE-768 (data was not an array (customfield_10150))

Note:  I have validated that "Work It" is indeed "customfield_10150"

 

What am I doing wrong?  Thanks!

2 answers

1 accepted

2 votes
Answer accepted
Alfonso Balsera March 30, 2020

@pbrdebruijn, this error is typically because the JSON is not correct when running the rule.

For fields that take an array of single field object:

 

{
    "fields": {
        "Multi User Customfield": {{issue.parent.Multi User Customfield.accountId.asJsonObjectArray("id")}}
    },
}

 

This webiste has some examples of how to use the JSON functions to ensure your values are compiled correctly: https://support.atlassian.com/jira-software-cloud/docs/advanced-field-editing-json/

 

This is where the function details are: https://support.atlassian.com/jira-software-cloud/docs/smart-values-json-functions/

Paul Benati March 31, 2020

Thanks for the response.  I was able to solve this need leveraging the array syntax even though this user field is single user constrained.  The working JSON is:

{
     "fields": {
          "Work It" : [ { "accountId":"5e7a27d154fac50c3bc1b488" } ]
     } 
}

Marc Isikoff May 1, 2023

That is odd that it works; I have a similar issue with single entry people picker but I am assigning the value (what Paul has as "5e7a..." from a text field (custom):

{
      "fields" : {
             "Work It" : [{"Username" : "{{issue.customfield_123456.value}}" }]
      }
}

 

And this gets (if [ ] are surrounding): "data was not an object (Work It))"

If I remove the [ ] it gets success but does not update Work it.

Mateo Colombo August 23, 2023

I am facing same issue @Marc Isikoff 

Did you manage to make it work?

Thanks!

Marc Isikoff September 6, 2023

Still working on it...

0 votes
Becca September 26, 2023

The following syntax worked for me so I could append a value from 1 custom field to a different, multi select custom field:

{
     "update": {
          "Custom Field 1": [{
               "add": {
                    "value": "{{issue.Custom Field 2}}"
                    }

               }]
          }
}

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