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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can extend that code a bit to fetch a value from the epic.
Issue epicIssue = (Issue) EpicValue
if(epicIssue) {
epicFieldValue = epicIssue.getCustomFieldValue(cField);
}
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.