Con queste righe di codice potrete aggiungere una nuova organizzazione ad un progetto Service Desk

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.util.paging.SimplePagedRequest 
  import com.onresolve.scriptrunner.runner.customisers.WithPlugin 
 
  @WithPlugin ( "com.atlassian.servicedesk" ) 

  def serviceDeskManager = ComponentAccessor.  getOSGiComponentInstanceOfType (ServiceDeskManager) 
  def organisationService = ComponentAccessor.  getOSGiComponentInstanceOfType (OrganizationService) 

  def adminUser = ComponentAccessor.  userManager .getUserByKey( "admin" ) 
  def project = ComponentAccessor.  projectManager .getProjectByCurrentKey("CRE") 

  def serviceDeskProject = serviceDeskManager.getServiceDeskForProject(project)

  def newOrgParams = organisationService
        .newCreateBuilder()
        .name("opopop")
        .build()
  
  def org = organisationService.createOrganization(adminUser,newOrgParams)

  def organizationServiceDeskUpdateParameters = organisationService
        .newOrganizationServiceDeskUpdateParametersBuilder()
        .organization(org.right().get())
        .serviceDeskId(serviceDeskProject.right().get().serviceDeskId)
        .build()

  organisationService.addOrganizationToServiceDesk(adminUser,organizationServiceDeskUpdateParameters)

 

Leave a Comment