Hello,
I've been trying to create a scripted field that returns the current user's organization ID. I tried with Rest Api but it doesn't work since i don't have my account ID.
Is there anyway to get the organization id? Even an idea can help :)
Have a nice day
A user could belong to more than one organization.
This script will give you all organization ids:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.organization.OrganizationService
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.atlassian.servicedesk") sdPlugin //this allows the import of com.atlassian.servicedesk*
@PluginModule OrganizationService organizationService //this is the service we will use
def user = ComponentAccessor.userManager.getUserByName('qadnexteer')
def emptyQuery = organizationService.newOrganizationsQueryBuilder().build()
def response = organizationService.getOrganizations(user, emptyQuery)
response.results*.id
Hello Peter,
It's working thank you. To get organization for specific project i just changed emptyQuery to :
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This solution provide all the organizations for Service Desk or an specific project, but not for the specific user. The 'user' parameter is used only as an agent to get all the organizations, not his organizations.
I haven't found any way to get all organizations for an specific user directly, only using nested loops.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.