Automatically adding request participants
Asked by Brandon Elie:

I have an incident request type which requires the submitter to choose which department(s) should be involved in the incident. Then through Jira automation, I'd like the associated department head(s) to be added as request participant(s) and then sent an email which contains a link to the issue. I've created two lookup tables:

* One for department and department head email address
* The other for departments and department head Jira account ID's

Using the branch/apply-to-each function to loop through the chosen departments and send emails one at a time works fine. However, trying to add request participants one at a time does not work - only one is added. Any ideas on what could be causing this issue? I've tried the normal and the advanced JSON method but still only one participant is added.

Also, happy to hear any different ways you think this same result could be achieved. Thought of creating and array of accounts ID's and adding in bulk but I'm not sure how to do this. For whatever reason, I'm an unable to create an object.


Answers:
author: Tessa Tuteleers
body: Hi [@Brandon Elie](/t5/user/viewprofilepage/user-id/5542595) ,

Welcome to the community!

Adding request participants one by one is best done using the advanced JSON method.

There are 2 things to look out for:

1. using the correct format -\> described [here](https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#:~:text=the%20trigger%20issue.-,Request%20participants,-The%20request%20participants)
2. Make sure you use the update + add, and not fields or set -\> described [here.](https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#:~:text=a%20new%20summary%22%0A%20%20%20%20%7D%0A%7D-,What%27s%20the%20difference%20between%20update%C2%A0and%20fields%3F,-fields%C2%A0is%20a)

If you can't get it to work, please add a screenshot of you advanced json method, so we can help debug :)

- Tessa

comments: author: Brandon Elie
body: Hi Tessa,

Thanks for the quick reply!

I just tested it again:

* I selected three departments in the field
* Only one of the associated users was added to the issue as a request participant.

Please see JSON below.

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

As I briefly mentioned:

* I initialise a variable called **Discipline** and set to value(s) of the multi-select field in the issue.
* I have a lookup table called **DisciplineXLeads** . The user account ID for current **Discipline** is then found.


author: Tessa Tuteleers
body: hi [@Brandon Elie](/t5/user/viewprofilepage/user-id/5542595) ,

I think I see the problem here.

Would it be possible to print (log) the smart value and show us what it returns?  
The add will ++add++ a single user to the values already in the field, this works as expected (I have tested it.)

However, you are trying to add a list of users all at once, I am wondering if what's in your variable is in the correct format.

It should be an array of json objects looking like this:

![Screenshot 2024-07-24 173631.png](https://community.atlassian.com/t5/image/serverpage/image-id/337688iEDB09837DF165B30/image-size/large?v=v2&px=999 "Screenshot 2024-07-24 173631.png")

If you already have a list, you can easily create this by doing the following:

```
{{yourListOfaccountIds.asJsonObject("id").asJsonArray}}
```

[Here](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-json-functions/#:~:text=string%20%E2%80%9CHello%20World%E2%80%9D.-,Chaining%20functions,-You%20can%20chain) is the supporting doc.

Hope this helps!

- Tessa


author: Brandon Elie
body: Hi Tessa,

By design, the smart value will return one Jira account ID from the lookup table. My automation is then supposed to loop through the other "Team" selections, if any, find the corresponding ID's in the table and add them as request participants one at a time. As I mentioned, in testing only one participant is added and the rest are ignored for some reason.

I just tested the smart value again by changing my automation to post a comment of the smart value(s). I selected three teams in the form and, as expected, three comments containing an ID were posted in the issue.

I have not tried the bulk add method as I cannot think of a way to append ID values together to create an array. Happy to try this way if you have an idea how to do it?

Brandon


author: Tessa Tuteleers
body: Hey [@Brandon Elie](/t5/user/viewprofilepage/user-id/5542595) ,

Iwasn't aware you were looping, apologies.

Before we go into creating the array, let's try to fix your loop.   
If you want to edit the same field multiple times (add request participants one by one), you will probably need to "save" the issue after every add. You can do that using the "Re-fetch issue data" action.

Try that and if it doesn't work, please show a screenshot of your work, so we can debug further.   

FYI, it would be cleaner to add all the participants in 1 update.

Tessa


author: Brandon Elie
body: Hi Tessa,

Thanks but that didn't work - as before, only 1 participant is added.

![JiraAutomation.png](https://community.atlassian.com/t5/image/serverpage/image-id/338793i3859831A4C030C77/image-dimensions/424x710?v=v2 "JiraAutomation.png")

* **DisciplineXLeads** - contains team names and Jira ID's or corresponding team leaders
* **Discipline** - the current selection in the multi-select field
* The second lookup table can be ignored

Please let me know how I could I create an ID array to bulk add request participants.

Regards,

Brandon


author: Brandon Elie
body: [@Tessa Tuteleers](/t5/user/viewprofilepage/user-id/24152) , any further suggestions would be greatly appreciated.


Tags: cloud

jira-service-management

jira-service-management-cloud