Hi
I am trying to create Workflow with the PostFunction in one of the steps to update one of the Number Custom Fields and getting error.
Looked everywhere ...
import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.Issue; def customFieldManager = ComponentAccessor.getCustomFieldManager() def issueManager = ComponentAccessor.getIssueManager() Issue issue = issue def cfRevisionMinor = customFieldManager.getCustomFieldObjectByName("Revision (Minor)") def cfErrataRevisionMinorVal = issue.getCustomFieldValue(cfErrataRevisionMinor) issue.setCustomFieldValue(cfErrataRevisionMinor, cfErrataRevisionMinorVal.toString() + 1 )
Not sure what I am doing wrong ...
Thanks,
Areg
Not sure why you are using toString there... "1" + 1 doesn't make much sense.
Otherwise seems OK.
Hi Jamie
When I am trying without toString inline compiler giving me error for "+ 1" ...
Not sure why.
I will share screen shot on Monday.
Regards,
Areg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Not sure what is wrong ..
2016-02-15 10:26:24,928 ajp-nio-8600-exec-10 ERROR username 626x557131x1 1jbpz3k 10.1.135.157 /secure/CommentAssignIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: ISSUE-1, actionId: 11, file: <inline script> java.lang.NullPointerException at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue(IssueImpl.java:1095) at com.atlassian.jira.issue.Issue$getCustomFieldValue$7.call(Unknown Source) at Script266.run(Script266.groovy:13)
Error.jpg
Regards,
Areg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Areg,
I can see two different issues. The first one is that you get a NullPointerException. Is the script you pasted in your original question the whole script ? If yes then in the lines
def cfRevisionMinor = customFieldManager.getCustomFieldObjectByName("Revision (Minor)") def cfErrataRevisionMinorVal = issue.getCustomFieldValue(cfErrataRevisionMinor) <-- should it be cfRevisionMinor ?
The second issue is in the screenshot you pasted, which is a static type checking where in some cases is safe to ignore. In your case you can correct it if type casting the
cfErrataRevisionMinorVal as Double
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thanos
Sorry for confusion - I was trying to do some tidy up and messed up in my question.
Here is the full code:
import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.Issue; def customFieldManager = ComponentAccessor.getCustomFieldManager() def issueManager = ComponentAccessor.getIssueManager() Issue issue = issue def cfErrataRevisionMinor = customFieldManager.getCustomFieldObjectByName("Errata Revision (Minor)") def cfErrataRevisionMinorVal = issue.getCustomFieldValue(cfErrataRevisionMinor) as Double issue.setCustomFieldValue(cfErrataRevisionMinor, cfErrataRevisionMinorVal + 1 )
Found NPE source - messed up with the Names - my bad.
All working now!
Regards,
Areg
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.