script runner doesn't work for a specific user (administrator)

When I use a normal user, the script works fine but when I use oalbertini (administrator) the script doesn't work...

here the error when I use oalbertini :

2015-02-27 10:42:46,730 http-bio-8090-exec-13 ERROR oalbertini 642x5796x1 1xwhhou   /secure/CommentAssignIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: ST-38045, actionId: 891, file: <inline script>
com.atlassian.jira.exception.CreateException: An unknown exception occured executing Validator com.atlassian.jira.workflow.SkippableValidator@2448ef3a: root cause: java.lang.NullPointerException
	at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:695)
	at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:618)
	at com.atlassian.jira.issue.IssueManager$createIssue.call(Unknown Source)
	at com.atlassian.jira.issue.IssueManager$createIssue.call(Unknown Source)
	at Script1.run(Script1.groovy:51)
Caused by: com.atlassian.jira.workflow.WorkflowException: An unknown exception occured executing Validator com.atlassian.jira.workflow.SkippableValidator@2448ef3a: root cause: java.lang.NullPointerException
	at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:909)
	at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:684)
	... 4 more
Caused by: com.opensymphony.workflow.WorkflowException: An unknown exception occured executing Validator com.atlassian.jira.workflow.SkippableValidator@2448ef3a: root cause: java.lang.NullPointerException
	at com.opensymphony.workflow.AbstractWorkflow.verifyInputs(AbstractWorkflow.java:1523)
	at com.opensymphony.workflow.AbstractWorkflow.initialize(AbstractWorkflow.java:615)
	at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:879)
	... 5 more
Caused by: java.lang.NullPointerException
	at com.atlassian.jira.workflow.validator.AbstractPermissionValidator.hasUserPermission(AbstractPermissionValidator.java:49)
	at com.atlassian.jira.workflow.validator.PermissionValidator.validate(PermissionValidator.java:46)
	at com.atlassian.jira.workflow.SkippableValidator.validate(SkippableValidator.java:52)
	at com.opensymphony.workflow.AbstractWorkflow.verifyInputs(AbstractWorkflow.java:1512)
	... 8 more
2015-02-27 10:42:51,123 ISSUE-indexQueue:thread-1 INFO oalbertini 671x925x1 m1jov7    /secure/admin/jira/IndexReIndex.jspa [action.admin.index.IndexAdminImpl] Re-indexing is 65% complete. Current index: Issue

 

Here my script :

 

import com.atlassian.jira.user.UserUtils
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.util.ImportUtils
import com.atlassian.crowd.embedded.api.User
import com.opensymphony.workflow.WorkflowContext
import org.apache.log4j.Category
import com.atlassian.jira.issue.fields.CustomField
 
log = Category.getInstance("com.onresolve.jira.groovy.CreateDependentIssue")
 
// Configurable section
def projectName = "Technician" // Name of project you want to create the issue in
def CustomTechFieldName = "customfield_11812"
def CustomLocationName = "customfield_10312"
def CustomTerminalName = "customfield_11811"
def customFieldManager = ComponentManager.getInstance().getCustomFieldManager()

CustomField customFieldTech = customFieldManager.getCustomFieldObject(CustomTechFieldName)
CustomField customFieldLocation = customFieldManager.getCustomFieldObject(CustomLocationName)
CustomField customFieldTerminal = customFieldManager.getCustomFieldObject(CustomTerminalName)

def customFieldTechVal = issue.getCustomFieldValue(customFieldTech).name
def customFieldLocationVal = issue.getCustomFieldValue(customFieldLocation)
def customFieldTerminalVal = issue.getCustomFieldValue(customFieldTerminal)


// for other customisations change the code below

issueMgr = ComponentManager.getInstance().getIssueManager()
projectMgr = ComponentManager.getInstance().getProjectManager()
 
String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();
User currentUserObj = UserUtils.getUser(currentUser);

def wasIndexing = ImportUtils.indexIssues
ImportUtils.indexIssues = true
issueFactory = ComponentManager.getInstance().getIssueFactory()
newissue = issueFactory.getIssue()
newissue.setSummary (issue.summary+"- "+customFieldTerminalVal)
newissue.setProject (projectMgr.getProjectByName(projectName))
newissue.setIssueType (issue.getIssueType())
newissue.description = issue.description
newissue.assignee = UserUtils.getUser(customFieldTechVal);
newissue.reporter = issue.getAssignee()
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Location'}
newissue.setCustomFieldValue(cf, issue.getCustomFieldValue(cf))
 
params = ["issue":newissue]
subTask = issueMgr.createIssue(currentUserObj, params)
println subTask.get("key")
 
// get the current list of outwards depends on links to get the sequence number
linkMgr = ComponentManager.getInstance().getIssueLinkManager()
def sequence = 0
for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
    if ("Blocks" == link.issueLinkType.name) {
        sequence++;
    }
}
 
linkMgr = ComponentManager.getInstance().getIssueLinkManager()
// TODO: Should check that 10000 is always the link id for Blocks
linkMgr.createIssueLink (newissue.id, issue.id, 10000, sequence, currentUserObj)
ImportUtils.indexIssues = wasIndexing

 

With the user oalbertini, the script always fails. If I use a different user for the same issue and transition, the script works...


The same problem occurs on different scripts.

This script is executed on JSD project. When an agent change the status "Waiting for support" to "Waiting for Technician"

2 answers

This widget could not be displayed.

Does oalbertini have permissions to create an issue or whatever you're doing in the UI? JSD seems to be causing all kinds of weird problems.

This widget could not be displayed.

Yes I can do everything on all projects included this project. and I'm an agentscript runner.PNG

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

484 views 3 18
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you