Forums

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

ScriptRunner to remove a Service Desk Customer from All Organizations

David Harkins
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 21, 2023

We have over 1000 Organizations and working on a more reliable way to automate our user management processes.

This is the last segment, before adding users to their correct organization, we need to ensure they are not associated with any other.

Currently working on a script to obtain all organizations and the customers for each, the script will then need look through the Organizations & Customer Map to them remove the user from that organization.

Has anyone done something similar?

1 answer

1 accepted

2 votes
Answer accepted
Ravi Sagar _Sparxsys_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 21, 2023

Hi @David Harkins 

I did this (and a bit more) few months ago for a client.

Have you checked the following?

import com.atlassian.servicedesk.api.organization.OrganizationService
import com.atlassian.servicedesk.api.organization.OrganizationsQuery

I cannot share the entire code (because someone paid me for it) :) but let me share the part that removes the users from an organisation.


otherOrganizations.each {organizationToRemoveFromUser ->
def removeUsersParam = organizationService
.newUsersOrganizationUpdateParametersBuilder()
.organization(organizationToRemoveFromUser as CustomerOrganization).users(usersToAdd).build()
organizationService.removeUsersFromOrganization(currentUser, removeUsersParam)
I hope it will give you enough pointers.
Ravi

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events