---
title: "Code snippet to access the members of an Organization"
canonical: "https://support.appfire.com/space/JMWE/461538012/Code%20snippet%20to%20access%20the%20members%20of%20an%20Organization"
format: markdown
---
> Macro (aura-html)

### Abstract

This code snippet accesses the members of an Organization

### Logic

- Fetch the Organizations of the issue
- Fetch the users in these Organizations and return them

### Snippet

```groovy
import com.atlassian.servicedesk.api.organization.OrganizationService
import com.atlassian.servicedesk.api.util.paging.SimplePagedRequest

def orgs = issue.get("Organizations");
if (!orgs)
    return [];
def organizationService = getComponent(OrganizationService)
def pagedRequest = SimplePagedRequest.paged(0,1000)
Set users = []

for (org in orgs) {
    def query = organizationService.newUsersInOrganizationQuery().customerOrganization(org).pagedRequest(pagedRequest).build()
    result = organizationService.getUsersInOrganization(currentUser, query)
    if (result.isRight())
      users.addAll(result.getRight().getResults())  
}
return users;
```

### Placeholders

N/A

### Examples

<span style="color: #333333">The outcome of the code snippet is a collection of users which can be used to set a Multi-user picker field in one of the Set field value post-functions for example to Add the members of the Organizations to the Watchers.</span>

### References

- [getComponent()](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461799437)
- [**Groovy Documentation**](http://groovy.codehaus.org/User+Guide)

### Related articles

> Macro (contentbylabel)

> Macro (details)
> 
> | **Related issues** |  |
> | --- | --- |