Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Get Current user's organization



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

1 answer

1 accepted

1 vote
Answer accepted

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)


Hello Peter, 

It's working thank you. To get organization for specific project i just changed emptyQuery to :

def emptyQuery = organizationService.newOrganizationsQueryBuilder().serviceDeskId("ProjectID").build()


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.


Suggest an answer

Log in or Sign up to answer