Question regarding Jira Service Desk and Behavior

Niraj Kumar May 9, 2023

What am i doing:

 

I am trying to create a dynamic form that will fetch data from an API and will display the values as the user use the form. Eg: A user selects a list of services -> It lists the all the available values from the above service -> And continues further based on the what the user is selecting.

I have so far been able to:

1. Created a single choice custom field.

2. Created a single select field for listing the values from the choice of service selected.

3. Set a behavior that points to the #1 field and set the target field(#2) with the values.

4. Able to list the values in the form

 

I have not been able to do so far:

1. Not been able to read the values from step #2 of I have so far been able to

2. While reading the above value, the value is represented as null

3. Value from the log

```

2023-05-09 15:48:30,859+0000 https-jsse-nio-8443-exec-5 url: /rest/scriptrunner/behaviours/latest/jsd/jsd/runvalidator.json; user: xxxxxxxxxxxx WARN xxxxxxxxxxxxxxx 948x80780x1 siy15h 15.65.252.11,172.17.99.83 /rest/scriptrunner/behaviours/latest/jsd/jsd/runvalidator.json [c.o.scriptrunner.runner.ScriptBindingsManager] currentField Form field ID: customfield_10940, value: null

```

3. My code

```

import com.atlassian.jira.component.ComponentAccessor
 
// Define Managers
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
 
def currentField = getFieldById(getFieldChanged())
def currentselectedOption = currentField.getValue() as String
 
log.warn("currentField ${currentField}")
```
Thanks in advance and please let me know if you need any other info.
Regards,
Niraj

1 answer

0 votes
Ken McClean
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 9, 2023

One of the challenges I have faced in the past is that with JSM, the values of custom fields aren't written to the field (in the database) until the issue is created.  This may be the limitation you're running into.

Niraj Kumar May 9, 2023

@Ken McClean Do you have any suggestions on moving forward with your experience with JSM?

Ken McClean
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 9, 2023

We ended up doing a lot of post-processing with a ScriptRunner script. i.e. a listener that listens for issue creation, and if it meets certain criteria, make the changes. For example, if the issue has a value of X in a custom field, set the value of a second custom field to Y.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events