Hi, Im getting syntax errors from the below script when I try to read email addresses from the Issue Organizations. It's returning the correct output in the log and the logic seems to be working. But for some reason it has syntax errors. Can someone please help? Thanks.
import com.adaptavist.hapi.jira.users.Users
import com.atlassian.servicedesk.api.ServiceDeskManager
import com.atlassian.servicedesk.api.organization.OrganizationService
import com.atlassian.servicedesk.api.organization.OrganizationsQuery
import com.atlassian.servicedesk.api.util.paging.SimplePagedRequest
import com.atlassian.servicedesk.internal.feature.organization.model.CustomerOrganizationImpl
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.atlassian.servicedesk")
@PluginModule
ServiceDeskManager serviceDeskManager
@PluginModule
OrganizationService organizationService
def issuesForOrganizations = Issues.getByKey('XXX-1010')
def customerOrg = issuesForOrganizations.getCustomFieldValue('Organizations') as List<CustomerOrganizationImpl>
def loggedInUser = Users.loggedInUser
def serviceDeskProject = serviceDeskManager.getServiceDeskForProject(issuesForOrganizations.projectObject)
def serviceDeskId = serviceDeskProject.id as Integer
// get the available organizations for that project
Boolean NextPageCheck = true
Integer StartRequest = 0
def organizationsResults = []
do {
OrganizationsQuery organizationsQuery = organizationService.newOrganizationsQueryBuilder().pagedRequest(new SimplePagedRequest(StartRequest,50)).build()
def result = organizationService.getOrganizations(loggedInUser, organizationsQuery)
organizationsResults.addAll(result?.toList())
NextPageCheck = result.hasNextPage()
StartRequest = StartRequest + result.size()
} while (NextPageCheck)
def usersInOrganizations = new StringBuilder()
if (organizationsResults != null) {organizationsResults.each { organization ->
customerOrg['name'].each {
if (it == organization.name ) {
def usersInOrganizationQuery = organizationService
.newUsersInOrganizationQuery()
.customerOrganization(organization)
.pagedRequest(new SimplePagedRequest(0, 50))
.build()
usersInOrganizations.append(organizationService.getUsersInOrganization(loggedInUser, usersInOrganizationQuery).results.collect {it.emailAddress}.join(',')).append(',')
}
}
}}
log.warn "====>>> ${usersInOrganizations.toString().replaceFirst('.$','') }"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.