Hi, i'm trying to do a post function with a script on create transition using scriptrunner. The script works fine in a script console, but doesn't work in the post function. In a log file i've got these lines:
2016-06-23 03:29:59,479 http-bio-8080-exec-10 DEBUG username 209x43885x1 1vm5o8z ip /secure/QuickCreateIssue.jspa [ScriptRunner AutoAssign] Current issue keynull 2016-06-23 03:29:59,493 http-bio-8080-exec-10 ERROR username 209x43885x1 1vm5o8z ip /secure/QuickCreateIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] ************************************************************************************* 2016-06-23 03:29:59,493 http-bio-8080-exec-10 ERROR Fyedorov.k 209x43885x1 1vm5o8z ip /secure/QuickCreateIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: null, actionId: 1, file: <inline script> java.lang.NullPointerException: Cannot get property 'assignee' on null object at Script61.run(Script61.groovy:23) 2016-06-23 03:29:59,779 http-bio-8080-exec-10 ERROR username 209x43885x1 1vm5o8z ip /secure/QuickCreateIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] ************************************************************************************* 2016-06-23 03:29:59,780 http-bio-8080-exec-10 ERROR username 209x43885x1 1vm5o8z ip /secure/QuickCreateIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: null, actionId: 1, file: <inline script> java.lang.NullPointerException: Cannot get property 'issue' on null object at Script65.run(Script65.groovy:11)
Issue object is always null. Any ideas? Thanks and sorry for my english, i'm not native speaker.
We need to see the script really. (Ideally, letting us know which are lines 23 in the first one, and 11 in the second script)
Here it is:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.user.util.UserManager def issueManager = ComponentAccessor.getIssueManager() def userManager = ComponentAccessor.getUserManager() def issueService = ComponentAccessor.getIssueService() def defaultAssignee = userManager.getUserByName("somename").getKey() def projectLead = userManager.getUserByName("anothername").getKey() def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() def curIssue = issueManager.getIssueObject(issue.id) if (!curIssue.assignee) { //def validateAssignResult = issueService.validateAssign(user, curIssue.id, defaultAssignee) def validateAssignResult = issueService.validateAssign(user, curIssue.id, defaultAssignee) issueService.assign(user, validateAssignResult) } else { //def validateAssignResult = issueService.validateAssign(user, curIssue.id, projectLead) def validateAssignResult = issueService.validateAssign(user, curIssue.id, projectLead) issueService.assign(user, validateAssignResult) }
Log record points to line with "if" statement.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, great. The line above the "if" is wrong, and also redundant, because a post-function already has access to "current issue"
Try removing that line and changing the if to
if ( !issue.assignee ) {
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So I know it, but the same problem with using only "issue" object.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, you'll need to do some sets of full debugging - on the line before the if, add a line
log.debug(issue)
The output will be ugly, and it'll be in the log that you quoted in your original question, but it should tell us whether there's something wrong with the issue object.
(Oh, you need to add some supporting code at the top of your script to enable logging - see https://www.adaptavist.com/doco/display/SFJ/Set+logging+to+help+debug+your+scripts )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, helped a lot. I've fixed it. I placed post function after "Creates the issue originally" function and now it works!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ahh, fantastic! I should have read the "on create transition" more carefully and rememered to ask you to check the position. Sorry!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please help on my code, It was working from last 2 months but suddenly it has stopped working.
I have tried to use behaviour , but after using behaviour function it stopped working so I deleted that behaviour.
But even after deleting it , the post function is not working.
Please check my code and error I have faced.
please help immediately my production is facing issues due ti this
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.