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
@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)
Hey Ian,
I've managed to get your code working, so for everyone else looking for an example, here is a solution:
@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)
Set<com.atlassian.jira.user.ApplicationUser> users = [newUser]
UsersOrganizationUpdateParameters param = organizationService.newUsersOrganizationUpdateParametersBuilder().organization(org).users(users).build()
organizationService.addUsersToOrganization(user, param)
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.