Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ScriptRunner Bulk Copy SLA Issue

Hello,

I am currently working on a post function script to bulk copy SLA to projects. However, I am getting a java.lang.NullPointerException error. Any advice on how can I achieve this?

Here's my script currently:

import com.onresolve.scriptrunner.canned.jira.admin.ServiceDeskBulkCopySLA

def copySLA = new ServiceDeskBulkCopySLA()

ServiceDeskBulkCopySLA.FIELD_DELETE_TARGET_SLA
def inputs = [
(ServiceDeskBulkCopySLA.FIELD_DELETE_TARGET_SLA):"on",
(ServiceDeskBulkCopySLA.FIELD_SOURCE_PROJECT) : "Project1",
(ServiceDeskBulkCopySLA.FIELD_TARGET_PROJECTS) : ["Project2"],
]

copySLA.doScript(inputs)

Here's the log:

java.lang.NullPointerException: Cannot invoke method getServiceDeskProfileBean() on null object
at com.onresolve.scriptrunner.canned.jira.admin.ServiceDeskBulkCopySLA.getSlaService(ServiceDeskBulkCopySLA.groovy:41)
at com.onresolve.scriptrunner.canned.jira.admin.ServiceDeskBulkCopySLA.getProperty(ServiceDeskBulkCopySLA.groovy)
at com.onresolve.scriptrunner.canned.jira.admin.ServiceDeskBulkCopySLA$_doScript_closure3.doCall(ServiceDeskBulkCopySLA.groovy:133)
at com.onresolve.scriptrunner.canned.jira.admin.ServiceDeskBulkCopySLA.doScript(ServiceDeskBulkCopySLA.groovy:131)
at com.onresolve.scriptrunner.canned.CannedScript$doScript$1.call(Unknown Source)
at Script935.run(Script935.groovy:12) 

 

1 answer

I grappled with this one a bit, too, until I ran into a possible workaround on a Confluence thread. Try this:

import com.onresolve.scriptrunner.canned.jira.admin.ServiceDeskBulkCopySLA
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl

def copySLA = ScriptRunnerImpl.scriptRunner.createBean(ServiceDeskBulkCopySLA)
def inputs = [
(ServiceDeskBulkCopySLA.FIELD_DELETE_TARGET_SLA): true,
(ServiceDeskBulkCopySLA.FIELD_SOURCE_PROJECT) : "KEY1",
(ServiceDeskBulkCopySLA.FIELD_TARGET_PROJECTS) : ["KEY2"],
]

def result = copySLA.doScript(inputs)

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you