Hi,
I'm trying to use this sample script to add organization on create but I'm having compiling issues
import com.atlassian.fugue.Option import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.ModifiedValue import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import com.atlassian.servicedesk.api.ServiceDeskManager import com.atlassian.servicedesk.api.organization.OrganizationService import com.atlassian.servicedesk.api.organization.OrganizationsQuery import com.atlassian.servicedesk.api.util.paging.LimitedPagedRequest import com.atlassian.servicedesk.api.util.paging.LimitedPagedRequestImpl import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin @WithPlugin("com.atlassian.servicedesk") @PluginModule ServiceDeskManager serviceDeskManager @PluginModule OrganizationService organizationService MutableIssue issue = issue def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() def serviceDeskProject = serviceDeskManager.getServiceDeskForProject(issue.projectObject) // if the project is not a Service Desk one then do nothing if (serviceDeskProject.isLeft()) { log.error "${serviceDeskProject?.left()?.get()}" return } def serviceDeskId = serviceDeskProject?.right()?.get()?.id as Integer // get the available organizations for that project def organizationsQuery = new OrganizationsQuery() { @Override Option<Integer> serviceDeskId() { return new Option.Some<Integer>(serviceDeskId) } @Override LimitedPagedRequest pagedRequest() { return new LimitedPagedRequestImpl(0, 50, 100) } } // get all the organizations configured for that project def organizationsToAdd = organizationService.getOrganizations(currentUser, organizationsQuery)?.right()?.get()?.results // get the Organizations custom field def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Organizations") // finally update the organizations custom field cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf), organizationsToAdd), new DefaultIssueChangeHolder())
The compiling issues are related with two lines of code
1. def serviceDeskId = serviceDeskProject?.right()?.get()?.id as Integer
2. def organizationsToAdd = organizationService.getOrganizations(currentUser, organizationsQuery)?.right()?.get()?.results
Both return the error (No such property id for class: R or No such property results for class: R)
If I try to log serviceDeskProject?.right()?.get() I get the result below:
I want to get the value 3 from serviceDeskId but I'm unable to do it. I did already try
serviceDeskProject?.right()?.get()?.getId as Integer and serviceDeskProject?.right()?.get()?.serviceDeskId as Integer but I still get the same compilation error (No such property id for class: R or No such property results for class: R)
serviceDeskId :Either.Right(ServiceDeskImpl{serviceDeskId=3, projectId=12502, projectName=ITSM TEST, accessConfig=AccessConfig{publicSignUp=false, openAccess=true}, createdByUserKey=some(afr), createdDate=some(2018-03-19 11:32:11.095), createdWithEmptyProject=some(true), createdAtVersion=some(3.11.0-REL-0005), legacyCommentTransitionDisabled=true})