Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Fetch field value from Epic and display this value in Story

Cédric Bochsler June 21, 2017

 

Hi all,

I hope someone's able to help me here. What we're trying to do with the Scriptrunner add-on for JIRA is to fetch a specific field value and display this value in a scripted field. What we have so far is this:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;

enableCache = { -> false }

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

CustomField EpicLink = customFieldManager.getCustomFieldObjectByName('Epic Link');
	def EpicValue = issue.getCustomFieldValue(EpicLink);

CustomField cField = customFieldManager.getCustomFieldObjectByName('SAP Project Number');
	def cFieldValue = EpicValue.getCustomFieldValue(cField);

 

Actually it works (the desired value get fetched and displayed at the right place) but in the catalina lo and also in scriptrunner it shows us an error saying:

 

[Static type checking] - Cannot find matching method

java.lang.Object#getCustomFieldValue

(com.atlassian.jira.issue.fields.CustomField). Please check if the declared type is right and if the method exists.

 

In the log I can see this:

2017-06-21 16:57:21,724 http-nio-8080-exec-24 ERROR bocadm 1017x29651x2 14z5dx 10.55.54.56,10.130.30.9 /rest/scriptrunner-jira/latest/scriptfields/12705/preview [c.o.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: AFP-20197, field: SAP Project Number from Epic
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.fields.ImmutableCustomField.getCustomFieldValue() is applicable for argument types: (com.atlassian.jira.issue.fields.ImmutableCustomField) values: [SAP Project Number]
Possible solutions: getCustomFieldValues(java.util.Map), getCustomFieldType()
at Script22.run(Script22.groovy:13)

 

Does anybody have a clue how to fix this?

 

Thanks and regards,

Cédric

 

1 answer

0 votes
Daniel Yelamos [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 26, 2017

Hello mate:

I believe you got an error in your last line:

It should be issue, and not EpicValue. Try this:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;

enableCache = { -> false }

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

CustomField EpicLink = customFieldManager.getCustomFieldObjectByName('Epic Link');
 def EpicValue = issue.getCustomFieldValue(EpicLink);

CustomField cField = customFieldManager.getCustomFieldObjectByName('SAP Project Number');
 def cFieldValue = issue.getCustomFieldValue(cField);

Cheers!

DYelamos

Cédric Bochsler July 26, 2017

Hi Dani,

Thanks but this doesn't help. I tried this already. The thing is we wan to fetch a specific field value from a parent/epic issue and display this value in a scripted field in a child/story issue.

Any ideas?

 

Regards,

Cédric

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 26, 2017

You can extend that code a bit to fetch a value from the epic.

Issue epicIssue = (Issue) EpicValue
					
if(epicIssue) {
epicFieldValue = epicIssue.getCustomFieldValue(cField);
}

 

Cédric Bochsler July 26, 2017

Thanks Nic! This has fixed our problem.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events