Hello,
I have been trying to create a scripted field on a sub-task. This scripted field will display data from the parent issue. This field is a numeric value custom field
Parent Issue - Improvment
Custom Field - DBA Estimate (Numeric)
Sub-Task
Scripted field - Parent DBA Estimate
The script I've created isn't working correctly -
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
def abc123 = issue.parentObject.getCustomFieldValue("DBA Estimate");
return abc123;
Here's the correct code:
import com.atlassian.jira.issue.Issue; import com.atlassian.jira.ComponentManager; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.component.ComponentAccessor; def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("DBA Estimate") def abc123 = issue.parentObject.getCustomFieldValue(field); return abc123;
Also make sure to set template : Number Field on the scripted field and also set the searcher to Number Searcher
Dear Borris,
Tried the same but getting below error response.
2020-10-09 10:35:49,734 ERROR [runner.ScriptFieldPreviewRunner]: ************************************************************************************* 2020-10-09 10:35:49,734 ERROR [runner.ScriptFieldPreviewRunner]: Script field preview failed for field that has not yet been created org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script32.groovy: 2: unable to resolve class com.atlassian.jira.ComponentManager @ line 2, column 1. import com.atlassian.jira.ComponentManager; ^ 1 error
what i am missing?
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.