I would like to set the organisation for a user on a transition.
Using the organisation linked to an issue then I want to assign the same organisation to a customer.
I am attempting to use this function but cannot get it working, I know its not right any assistance would be greatly appreciated
addUsersToOrganization
@WithPlugin("com.atlassian.servicedesk")
@PluginModule
ServiceDeskManager serviceDeskManager
@PluginModule
OrganizationService organizationService
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cfOrganisation = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Organizations")
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cfUserPicker = customFieldManager.getCustomFieldObject(11901L)
def organisation = issue.getCustomFieldValue(cfOrganisation)
ApplicartionUser user = issue.getCustomFieldValue(cfUserPicker)
UsersOrganizationUpdateParameters param = organizationService.newUsersOrganizationUpdateParameters().customerOrganisation(organisation).users(newUser).build()
organizationService.addUsersToOrganization(user, param)