I've been searching for days, I've also tried various scripts to try to get all the organizations under 1 servicedesk project, but I've had no luck.
The below is a light edit of a script i found below:
The thing is, I just want a list of the organizations, I don't care about the users and I don't have a issue to reference of. I know you can do this via the Jira REST API, however I don't want to do this from within my post functions.
Can anyone help me out here? The errors I currently get is that it tells me that this line:
def organizationsQuery = organizationService.newOrganizationsQueryBuilder().serviceDeskId().build()
"Cannot find matching method"
and then after that this line:
def organizationsToAdd = organizationService.getOrganizations(sdUser, organizationsQuery)?.right()?.get()?.results
Also "Cannot find matching method"
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.servicedesk.api.ServiceDeskManager
import com.atlassian.servicedesk.api.organization.OrganizationService
import com.atlassian.servicedesk.api.organization.OrganizationsQuery
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 sdUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
//get SD ID
def serviceDeskId = 16 as Integer
//Build Org Query
def organizationsQuery = organizationService.newOrganizationsQueryBuilder().serviceDeskId().build()
// get all the organizations configured for the project
def organizationsToAdd = organizationService.getOrganizations(sdUser, organizationsQuery)?.right()?.get()?.results
log.info((String)organizationsToAdd)
Please see https://community.atlassian.com/t5/Jira-questions/Scripts-works-fine-in-ScriptRunner-Fails-in-Groovy/qaq-p/1158145#U1159147 in regards to a working solution for this type of request.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.