Editing custom JPD fields through Automation causes errors
Asked by Mart Postma:

Hi all,

I'm trying to set up an automation rule with the following logic:

* When I link a delivery ticket to an idea in JPD, I want the custom field of that idea (="Coral Component") to be set to one of the options of that custom field.
* Which option it should be depends on the Component (Jira Cloud) field of the delivery ticket.
* See my script below.

![automation rules.png](https://community.atlassian.com/t5/image/serverpage/image-id/291191iAFA780A54AF64D9C/image-size/large?v=v2&px=999 "automation rules.png")

But then somehow Jira Automation is not able to find that custom field in JPD, see:

![audit error.png](https://community.atlassian.com/t5/image/serverpage/image-id/291192i846C6A33660B3CDB/image-size/large?v=v2&px=999 "audit error.png")

Is there any solution to this error? Thanks!


Answers:
author: Mart Postma
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

Got a reply back from support: apparently there is an issue with the configuration of our Automation bot on our Atlassian site. Don't know if the issue is only applicable to our instance or if it is an Atlassian issue in general. Their engineering team is working on a fix.

comments: author: Rohan Parakh
body: [@Mart Postma](/t5/user/viewprofilepage/user-id/5313648) were you able to get this fixed? I am seeing the same issue


author: Mart Postma
body: Hi [@Rohan Parakh](/t5/user/viewprofilepage/user-id/5372878) - yes I was able to get this fixed with the help of Atlassian support.

The automation would run under my account, but not under the Automation for Jira account. At the time, I reached out to support and it looks like that only they can fix it, so not unfortunately yourself:
> That being said, we identified a small issue with the permissions granted to the Automation bot on your site and are already working on a fix. As soon as I get an update from the engineering team I'll let you know!

So if you have the permissions to do so, reach out to Atlassian JPD support and link this Community thread, or ask your (technical) Atlassian site admin to do so for you. They usually don't undertake any action based on issues on the Community pages.

Hope they can help you!


author: Marina Rambo
body: Are you using the **customfield_12345** configuration for calling out the field? Or are you using the name? I find the custom field is far more likely to work than the name.

**1 .** Find the custom field name of your issue by using the Jira API to inspect your JSON.

https://**yourdomain** .atlassian.net/rest/api/2/issue/**AAA-111**?expand=names

Replace "yourdomain" in the above with your jira workspace.

Replace "AAA-111" with an issue that has Coral Component selected.

**2.** Next search the JSON for "Coral Component".

This is easier if you use an online JSON IDE - I used [JSON Editor Online](https://jsoneditoronline.org). It will format your JSON so it is easier to read, and give you a search tool to find the info easier.

If you use it, copy and paste all the JSON that was returned from your REST API query above.

Once you find the line that says

"customfield_12345": "Coral Component",

you will know you found the right custom field.

Note: this does not address the rest of the automation, just may help find the field you are looking for.

comments: author: Mart Postma
body: Hi [@Marina Rambo](/t5/user/viewprofilepage/user-id/5358993)

Thanks for your elaborate reply.  

I have found the customfield_id for this field, but how can I now use this field to update/set the new value in the automation rule?


author: Marina Rambo
body: [@Mart Postma](/t5/user/viewprofilepage/user-id/5313648)

You would then go into \> More Options and edit the JSON. Here is some info on how to do that:

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

Hope that helps!


author: Mart Postma
body: Hi [@Marina Rambo](/t5/user/viewprofilepage/user-id/5358993) - CC: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

I updated the rule with the following JSON (note that XYZ and cf_123 are of course updated in my actual script):

```
{
   "update": {
      "customfield_123": [{
         "set": "XYZ"
      }]
   }
}
```

But unfortunately I still receive errors upon running:

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/291539i7E201A1F146A6D85/image-size/large?v=v2&px=999 "image.png")

Do I need a system-value for "set" as well, rather than the text-value "XYZ"? If so, how to find that one?  

Or if not, what could possibly fix this?  

Thanks once more!


author: Bill Sheboy
body: Mart, what is the type of your custom field: single-select, multiple-select, etc.? The type of field impacts which syntax to use for the JSON edit.


author: Mart Postma
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) - It is a multi-select field.  

Edit - also doesn't seem to work...:

```
{
   "update": {
      "customfield_123": [
         {"set": {"value": "XYZ"}}
      ]
   }
}
```


author: Bill Sheboy
body: Thanks for that information.

For a [multiple-select custom field, there are two syntaxes, depending on whether you want to replace all values or add additional ones](https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Multi-line-text-custom-field). FYI there are typos in the documentation, so I amended the "add" version to make it more clear.

To replace all please try this one:

```
{
  "fields" : {
    "customfield_12345" : [
     { "value" : "option1" }, { "value" : "option2" }
    ]
  }
}
```

To add additional values:

```
{
  "update" : {
    "customfield_12345" : [
      { 
        "add" : { "value" : "option 3" } 
      }
    ]
  }
}
```

Please use the one that matches your scenario and let us know what you observe. Thanks!


author: Mart Postma
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) [@Marina Rambo](/t5/user/viewprofilepage/user-id/5358993)   

Unfortunately still no success...

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/291849i9417B72A43FE7E41/image-size/large?v=v2&px=999 "image.png")

I'm afraid there is no other solution left other than using the web request in automation. Do you believe that would work?


author: Bill Sheboy
body: Let's checks some things first, as if they do not check out then the field cannot be edited with a Send Web Request to the REST API functions either.

First, have you confirmed that your field is on the views for the issue type in the target project, CORD?

Who is the actor for your rule? The default is Automation for Jira, which has permissions to change lots of things. If the actor was changed it is possible they do not have the necessary permissions.

Finally, let's confirm the field can be edited by automation rules using this how-to article. Essentially you find an example issue in your CORD project that has this field set, call a REST API function using a browser tab, and search for your field on the page (e.g., with CTRL-F). If the field is not present, rules cannot edit it. <https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/>


author: Mart Postma
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

First, have you confirmed that your field is on the views for the issue type in the target project, CORD? **-\> Yes**

Who is the actor for your rule? The default is Automation for Jira, which has permissions to change lots of things. If the actor was changed it is possible they do not have the necessary permissions. **-\> Automation for Jira, did not change the actor since creation. However, I think I found out that the issue lies there. When I change the actor role to my own account, the automation suddenly runs and executes as expected.**

Finally, let's confirm the field can be edited by automation rules using this how-to article. Essentially you find an example issue in your CORD project that has this field set, call a REST API function using a browser tab, and search for your field on the page (e.g., with CTRL-F). If the field is not present, rules cannot edit it. **-\> Yes, field is present.**


author: Bill Sheboy
body: At this point, I recommend working with your Jira site admin to submit a ticket to Atlassian Support, including a link to this thread. If you are on a paid Jira license, your admin can do that here:

<https://support.atlassian.com/contact/#/>

They may see something we are missing in the field or rule configuration. When you hear back from them, please share what you learn to benefit the community.


author: Bill Sheboy
body: Hi [@Mart Postma](/t5/user/viewprofilepage/user-id/5313648)

Some of the errors automation rules show do not always indicate the actual, root cause of a problem. For what your audit log shows, I wonder...

Automation rules which read / edit issues in multiple projects need to be global or multi-project in scope. A rule which is defined in a single project cannot do so.

What is the scope of your rule: single project or global / multi-project?

Kind regards,  
Bill

comments: author: Mart Postma
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)   

The automation scope is set to Global.