Hi,
My script working fine when tested on console but when implemented as post fuction script it failing for one of its case
Script functionality : To copy custome field value from parent to child issue on creation
Script failure case: when creating an epic which has no parent it give null pointer exception though i have if condition to check that still its trying to access custom field
script
if ( (issue.issueType.name != 'Epic') && issue != null) { def customFieldManager = ComponentAccessor.getCustomFieldManager(); CustomField epiclink = customFieldManager.getCustomFieldObjectByName("Epic Link"); def epic = issue.getCustomFieldValue(epiclink); if (epic != null) { Issue issue1 = ComponentAccessor.getIssueManager().getIssueByKeyIgnoreCase("$epic"); CustomField costcollector = customFieldManager.getCustomFieldObjectByName("Cost Collector"); def cost = issue1.getCustomFieldValue(costcollector); if (cost != null) { issue.setCustomFieldValue(costcollector, cost) } } }
Error:
2017-07-18 08:26:08,010 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2017-07-18 08:26:08,012 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: null, actionId: 1, file: <inline script> java.lang.NullPointerException: Cannot invoke method getCustomFieldValue() on null object at Script2.run(Script2.groovy:19)
Your error message implies that the custom field you're reading is not valid for the issue type you are running the script against.
Check for Epic with if(issue.getIssueType().getName() == "Epic")
Worked for me fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well dont know why it not working in console it working all well but when implemented in post fuction its give error but only in the case of epic creation as epic does not have any parent epic but when we create work package or task it works just fine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe on wrong position in postfunction?
When i upgraded to Jira 7 i had to move my create-postfunction scripts that do something with issue fields from second position (behind "Creates the issue originally") to the first position (before "Creates ..").
Maybe try some position changes.
Edit: For me the check for issuetype is working in create postfunction when script is on first position
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.
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.