Hello,
i am trying to set a formfield using a behaviour.
The data i am trying to set is read from another issue.
When i try to set the field value like this
Issue presetFound = (Issue) issueIterator.next()
Customfield field = customfieldManager.getCustomFieldObject(11603L)
java.lang.Object fieldValue = presetFound.getCustomFieldValue(field)
if (fieldValue != null) {
com.onresolve.jira.groovy.user.FormField formField = getFieldById(field.getId())
errorMessage += "set field " + field.getId() + " to " + fieldValue.toString() + ", field is " + formField.getClass().toString()
formField.setFormValue(fieldValue)
}
When i comment out the last statement the errorMessage is
set field customfield_11700 to KLE-VE-4753 field is class com.onresolve.jira.groovy.user.FormField
When the statement is not uncommented the beheviour is not executed and this errror is logged:
2018-10-30 16:41:43,441 http-nio-8080-exec-79 ERROR admin 1001x12741x1 1s5x3j9 80.147.223.246,127.0.0.1 /rest/scriptrunner/behaviours/latest/runvalidator.json [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: null
java.lang.StackOverflowError
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:62)
at groovy.lang.PropertyValue.getValue(PropertyValue.java:42)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.getProperties(DefaultGroovyMethods.java:389)
at groovy.json.JsonOutput.getObjectProperties(JsonOutput.java:327)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:320)
See here for the Full Exception
Hi @Jens Kisters __SeibertSolutions,
your are add an Object to custom field and this cause the error. Please, could you verify what is the type of your custom field?
If it is a text, you need to add String as value, if it is a select list you need to add an Option and so on.
Great, that was exactly the problem.
Thanks a lot!
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.
Hi Jens, can you provide the full working code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bryan,
i have nothing i can quickly paste for you, but the working version should be something like this (3rd line is the one with the change):
Issue presetFound = (Issue) issueIterator.next()
Customfield field = customfieldManager.getCustomFieldObject(11603L)
String fieldValue = (String) presetFound.getCustomFieldValue(field)
if (fieldValue != null) {
com.onresolve.jira.groovy.user.FormField formField = getFieldById(field.getId())
errorMessage += "set field " + field.getId() + " to " + fieldValue.toString() + ", field is " + formField.getClass().toString()
formField.setFormValue(fieldValue)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Am I the only one left wondering why this causes a StackOverflowError?
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.