Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

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

Code Block
languagegroovy
linenumberstrue
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

The outcome of the code snippet is a collection of users which can be used to calculate and display the members of the Organizations. For this, you need to create a calculated multi-select custom field type and write the above script in the field configuration.

References

Filter by label (Content by label)
showLabelsfalse
max5
spacesKB
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "jmcf-2" and type = "page"
labelsjmwe-nunjucks jmwe-cloud

...