Forums

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

Using Scriptrunner to populate organization

Jordan Berry
Contributor
May 22, 2019

We have the need to populate a few organizations, but doing that manually will take hours. I was hoping someone could point me in the right direction.

I have a list of users, and I would like to use the script console to fill an organization with that list of users.

I don't have much written yet, but here it is. Whenever looking for Users, it comes back Null (I know the variable naming is atrocious)

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.ServiceDeskManager
import com.atlassian.servicedesk.api.organization.CustomerOrganization
import com.atlassian.servicedesk.api.organization.OrganizationService
import com.atlassian.servicedesk.api.organization.UsersOrganizationUpdateParameters
import com.atlassian.servicedesk.api.util.paging.SimplePagedRequest
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager

@WithPlugin("com.atlassian.servicedesk")

def serviceDeskManager = ComponentAccessor.getOSGiComponentInstanceOfType(ServiceDeskManager)
def organisationService = ComponentAccessor.getOSGiComponentInstanceOfType(OrganizationService)
def users = ComponentAccessor.getOSGiComponentInstanceOfType(UsersOrganizationUpdateParameters)
def user = ComponentAccessor.getUserManager().getUserByName("Username")

users.users().add(user)

//organisationService.addUsersToOrganization("jberry@specialized.com", )
//def project = ComponentAccessor.projectManager.getProjectByCurrentKey("ITHELP")
//def adminUser = ComponentAccessor.userManager.getUserByKey("admin")


//log.warn adminUser;
//log.warn project;
log.warn user;
log.warn users;
log.warn "Done";

 Could anyone help point me in the right direction? I feel like I am missing something really obvious here. 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events