You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.