Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get all the organizations listed under a Servicedesk project

Ruben August 20, 2019

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:

https://community.atlassian.com/t5/Jira-questions/Scriptrunner-Adding-organizations-when-a-Service-Desk-issue-gets/qaq-p/924365

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)

 

1 answer

1 accepted

0 votes
Answer accepted
Ruben August 21, 2019

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events