Apps documentation
Extension for Jira Service Management
Cloud Server/Data Center
Extension for Jira Service Management

Cloud

Server/Data Center

Documentation
FAQ
Release notes
Articles & Videos
Last updated Aug 24, 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.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)

How to find a field’s ID

Navigate to Manage apps>Bundled fields>Subfields

  1. Open developer tools in your browser.
  2. Go to the Network tab.
  3. Find Bundled fields, use filter to find it quicker.
  4. The ID is right above the field’s name.
    Dynamic Forms for Jira
    Dynamic Forms for Jira

MissingGroupException: Unable to find group with index: 0

The MissingGroupException: Unable to find group with index: 0 error occurs when a bundled field is empty in the referred issue.

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.