Hi
Would really appreciate some help. I need to create a Service Desk Customer (as opposed to a 'user') via a Groovy script, but simply can't figure out how to use the builder correctly or find an example to work from. I'm on JSM v4.20.9 Data Centre.
I've tried every permutation I can think of. The very cut down version below yields "The script could not be compiled: <pre>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script2.groovy: 12: unable to resolve class newCreateBuilder"
Any help gratefully received!
import com.atlassian.servicedesk.api.user.CheckedUserimport com.atlassian.servicedesk.api.customer.CustomerServiceimport com.atlassian.servicedesk.api.customer.CustomerCreateParametersimport com.atlassian.jira.bc.user.UserServiceimport com.atlassian.jira.component.ComponentAccessordef loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUserCustomerCreateParameters.Builder customerPara = new newCreateBuilder();def customer = customerPara('demo.email@yahoo.com','A Name').build()def created = customerService.createCustomer(loggedInUser, customer)
My approach here would be a bit different: I would prefer to use the API to create a customer account cause the API makes it really easy to do that...
For version 4.20.x, there is an experimental API to create a customer:
https://docs.atlassian.com/jira-servicedesk/REST/4.20.0/#servicedeskapi/customer-createCustomer
Then you can code the API call with Scriptrunner like that:
I hope this helps.
Cheers,
Dam.
Hi
I wondered if that might be a good option with a couple of the Adaptavist Library 'recipes' heading in that direction, it just 'feels' odd making an API call when it appears the Class should be able to do it.
I hadn't found an example of using the API in that manner with a Post function so those links are awesome - thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Even for internal API calls let's say... and as many organisations consider the future in Cloud like @Phill Fox mentioned... using an API is much better in many cases ;)
I'm glad I helped here :)
Cheers,
Dam.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As many organisations consider the future in Cloud it makes sense to use the approach (APIs) that are largely consistent between the two hosting options. By doing so it simplifies any future migration as you do not then need to swap the use of classes to APIs just check the API definitions to make sure they are compatible.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.