Hello, I created an automation where I want to automatically add request participants using a variable, REST API, and JSON.
I found a problem: when I use the update operation to add a user to the request participants, I want to avoid overwriting the existing participants. However, it is still overwriting them instead of adding the new user.
I need to use a variable because the users are obtained dynamically from a Security Group in Microsoft Entra ID, and I don't know in advance how many users belong to the group.
Therefore, I need to add all the users from the Security Group to the request participants without overwriting the participants that are already there.
Does anyone know how I can achieve this using the REST API and JSON?
{
"update": {
"customfield_xxx": [
{
"add": {
"accountId": "{{participantAccountId}}"
}
}
]
}
}
👋 Hi Paola,
The reason the "update" block with the "add" verb didn't work in your case is that the Jira API and Jira Automation don't always handle the update operation syntax well for all custom field types via the visual interface. Often, it ignores the instruction or attempts to overwrite the field using the standard "fields" structure.
To ensure this works reliably, instead of using the "update" node, we switch to the "fields" node and use Jira Automation's native loop to rebuild the list.
The ideal structure for your code is this:
{
"fields": {
"customfield_xxx": [
{{#issue.customfield_xxx}}
{ "accountId": "{{accountId}}" },
{{/issue.customfield_xxx}}
{ "accountId": "{{participantAccountId}}" }
]
}
}What changes in practice:
This way, you don't rely on the API's "add" operation: you provide the combined list (current users + the new one) yourself, and Jira updates the field while keeping everyone included!
I hope this helps. 😁
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.