Find solutions for most common problems with the Bundled Fields Java API
Here’s a list of the most common error sources:
You may encounter the following exception while using both Dynamic Forms for Jira and Extension for Jira Service Management in your Jira instance:
2021-05-31 08:57:18,127 ERROR [common.UserScriptEndpoint]: Script console script failed:
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.deviniti.plugins.bundledfields.api.issue.BundledFieldImpl@67c66bcf' with class 'com.deviniti.plugins.bundledfields.api.issue.BundledFieldImpl' to class 'com.deviniti.plugins.bundledfields.api.issue.BundledField'
at Script69.run(Script69.groovy:39)
The problem comes from the fact that in a Groovy script, you can only import a class definition from one source at a time (for example, the BundledField class, as in the case below). Such a class definition is cached via the Groovy Script Engine. Then it is used in the context of the Bundled Fields component in all scripts - for both Dynamic Forms and Extension.
Therefore, the GroovyCastException will occur every time a Groovy script uses a Bundled Fields’ class definition from the other app.
You can solve this problem by using the def type instead of a class.
For example, when you get the GroovyCastException generated by such a script:
import com.deviniti.plugins.bundledfields.api.issue.BundledField
import com.intenso.jira.plugins.bundledfields.api.ExtensionBundledService
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import org.apache.log4j.Logger
import org.apache.log4j.Level
log.setLevel(Level.DEBUG)
String ISSUE_KEY = "BFT2-14";
String EXT_BF_CUSTOM_FIELD_ID = "customfield_10700";
@WithPlugin("com.intenso.jira.plugins.jsd-extender")
@PluginModule
ExtensionBundledService extensionBundledService
log.debug("bundledFieldService: " + extensionBundledService)
BundledField ext_bf = extensionBundledService.getBundledField(ISSUE_KEY, EXT_BF_CUSTOM_FIELD_ID)
log.debug("ext_bf.groups: " + ext_bf.getGroups())
instead of using this class for getting a bundled field:
BundledField ext_bf = extensionBundledService.getBundledField(ISSUE_KEY, EXT_BF_CUSTOM_FIELD_ID)
you can use this script:
def ext_bf = extensionBundledService.getBundledField(ISSUE_KEY, EXT_BF_CUSTOM_FIELD_ID)
Navigate to Manage apps>Bundled fields>Subfields
The MissingGroupException: Unable to find group with index: 0
error occurs when a bundled field is empty in the referred issue.
If you can’t find the answer you need in our documentation, raise a support request. Include as much information as possible to help our support team resolve your issue faster.