Apps documentation
Dynamic Forms for Jira
Dynamic Forms for Jira
6.x
5.x and older
FAQ
Release notes
Last updated Jun 17, 2021

Java API: Troubleshooting

Find solutions for most common problems with the Bundled Fields Java API

Info
  • Currently we don’t support ScriptRunner’s Behaviours.
  • To find available Java API methods and get more information about what’s supported, go the main Java API chapter.
  • To see an example of a Bundled Fields' JSON structure and descriptions of the attributes, go to Examples and definitions.

Cases that throw exceptions

Here’s a list of the most common error sources:

  • Providing a data type that is not compatible with the configured subfield’s type.
  • Exceeding the character limit (255) in a text field (single-line).
  • Trying to set a value for the separator (which is a technical field).
  • Providing a non-existent option as a value.
  • Providing a userKey of a non-existent user.
  • Providing a non-existent subfield name.
  • Providing a non-existent group index.
  • Providing an empty value for a required subfield.
  • Providing a value that is not compatible with the defined formatting, regular expression, or value mask.
  • Trying to exceed the configured number of groups for an issue.
  • Trying to create a new group without a required subfield.
  • Trying to perform an operation on a Bundled Field that hasn’t been configured (no configuration of such field has ever been saved).
  • Error during form validation while trying to update the issue (the possible reason may be a globally required field that hasn’t been filled).

GroovyCastException

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)

Problem description

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.

Solution

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.plugin.customfield.bundledfields.api.issue.BundledFieldDFService
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 DF_BF_CUSTOM_FIELD_ID = "customfield_10700";

@WithPlugin("com.intenso.jira.plugin.dynamic-forms")
@PluginModule
BundledFieldDFService bundledFieldDFService
log.debug("bundledFieldService: " + bundledFieldDFService)

BundledField df_bf = bundledFieldDFService.getBundledField(ISSUE_KEY, DF_BF_CUSTOM_FIELD_ID)
log.debug("df_bf.groups: " + df_bf.getGroups())

instead of using this class for getting a bundled field:

BundledField df_bf = bundledFieldDFService.getBundledField(ISSUE_KEY, DF_BF_CUSTOM_FIELD_ID)

you can use this script:

def df_bf = bundledFieldDFService.getBundledField(ISSUE_KEY, DF_BF_CUSTOM_FIELD_ID)
Need help?

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.