Script runner 3.0.9
JIRA 6.3.11
One user with the same right than me cannot create a task during a transition...
here the log :
2015-03-18 16:13:54,032 http-bio-8090-exec-21 ERROR fbernier 973x208702x1 108dwji 192.9.244.103,192.9.244.161 /secure/CommentAssignIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: ST-40171, actionId: 891, file: <inline script>
java.lang.NullPointerException
at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue(IssueImpl.java:1003)
at com.atlassian.jira.issue.Issue$getCustomFieldValue$0.call(Unknown Source)
at com.atlassian.jira.issue.Issue$getCustomFieldValue$0.call(Unknown Source)
at Script2.run(Script2.groovy:52)
Please, someone can help me azap ?
the 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 CustomTerminalName = "customfield_11811" def customFieldManager = ComponentManager.getInstance().getCustomFieldManager() CustomField customFieldTech = customFieldManager.getCustomFieldObject(CustomTechFieldName) //CustomField customFieldTerminal = customFieldManager.getCustomFieldObject(CustomTerminalName) def customFieldTechVal = issue.getCustomFieldValue(customFieldTech).name //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.setComponentObjects(issue.getComponentObjects()) 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
Hi @Olivier Albertini,
It looks like when you are trying to call
def customFieldTechVal = issue.getCustomFieldValue(customFieldTech).name
you are getting a null pointer exception.
That is probably happening because customFieldTech is not present (is null) in the issue from which the other user is trying to call the transition. Therefore an exception is thrown due to the fact that you are trying to retrieve the property "name" from a null object.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.