i am trying to copy custom field value from parent to all child issues and using the below code
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
def issue = event.issue
def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObject('customfield_13202')
def parentMyFieldValue = issue.parentObject.getCustomFieldValue(field)
def changeHolder = new DefaultIssueChangeHolder();
field.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(field), parentMyFieldValue),changeHolder);
getting error as below
Log:
2020-09-10 16:59:14,964 ERROR [runner.AbstractScriptListener]: ************************************************************************************* 2020-09-10 16:59:14,965 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: null java.lang.NullPointerException: Cannot invoke method getCustomFieldValue() on null object at Script320.run(Script320.groovy:11)o
Hi @Uday Kiran Raparthy
I think your code is correct, but something else is causing the problem.
This is where the null pointer happens
def parentMyFieldValue = issue.parentObject.getCustomFieldValue(field)
field is null, so it was never assigned in the previous line.
def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObject('customfield_13202')
Is that the correct customfield id ?
You can also try with getCustomFieldObjectByName("Your Custom Field Name") to see if you get the same error.
If you do, I think your customField is not present in that project or in that particular issue type.
Hope this helps you.
i tried with getCustomFieldObjectByName("Your Custom Field Name") but still see same issue. and the customField is present in that project or in that particular issue type.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
def issue = event.issue
def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName('ProjectStatus')
def parentMyFieldValue = issue.parentObject.getCustomFieldValue(field)
def changeHolder = new DefaultIssueChangeHolder();
field.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(field), parentMyFieldValue),changeHolder);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I just replicate the error.
Your are using a script listener, maybe with issue created?
But every type of issue is entering there.
I have an if
if(issue.issueTypeId.equalsIgnoreCase("10003")){
//your code
}
That way I'm sure the code is executed only when the issue type is a subtask.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here, i'm using Issue Updated Event.
The Scenario is i'm trying to copy field value from feature to its child issues(Story's and Bug's)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, but what is getting updated to trigger the script listener?
If you update the feature, then It would execute your code and fail, because your feature doesnt have a parent.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
updating the child issue(story) so that listener gets triggered and it copies value from parent feature
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The error is that your story doesnt have a parent.
How do you set that parent relationship on your story and on your bugs?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
relationship was maintained through a custom-field "Feature link"
see the below screenshot, i was trying to update 'Projectstatus' field on the below child issues
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I dont know about Issue in Feature, but I think it's the same functionality as Epics, Issue in Epic.
this works in epics:
def epicLink = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Epic Link")
Issue epic = issue.getCustomFieldValue(epicLink) as Issue
def parentValue = epic.getCustomFieldValue(epicLink)
If it has the same functionality, something like this would work for you
def featureLink = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Feature Link")
Issue parentFeature= issue.getCustomFieldValue(featureLink ) as Issue
def parentValue = parentFeature.getCustomFieldValue(featureLink )
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.