Populating the description using convert to single select in jira script

Gowri_Sankar November 3, 2019

Hi,

I've been working on populating a custom field by converting the text box into drop down by referring to 

https://scriptrunner.adaptavist.com/4.3.5/jira/behaviours-conversions.html

 

I was able to narrow down the desired list. However, when I choose the list from the drop down,  summary of the selected value is not populated where we could see only the key for the selected value. Eg: If I selected ABC21 - Test from the drop down, then only ABC21 is populated in the custom field. I've been using JQL query to fetch the resultant set in the drop down. 

 

Can anyone help in populating the field along with the summary.

1 answer

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 4, 2019

What you are describing is the default behavior using the example in the documentation.

To help you further, it would help to see your exact code.

This is what it looks like in my test:

2019-11-04 19_37_30-Edit Issue _ JSP-1922 - JIRA Test - Corporate Issue Tracker - https___projects-t.png

Gowri_Sankar November 4, 2019

Hi @Peter-Dave Sheehan ,

 

Yes,  the default behavior displays as you provided in the screenshot. But when I click on update the task number will be updated only as JSP-3. The summary is not updated.

I've used the below code for retrieval of lists. 

getFieldByName("ABC").convertToSingleSelect([
ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner-jira/latest/issue/picker",
query: true, // keep going back to the sever for each keystroke

// this information is passed to the server with each keystroke
data: [
currentJql : ajaxQueryString + ajaxQueryString2,
label : "Products: "+productNames,
showSubTasks: true,
max : 100,
],
formatResponse: "issue"
],
css: "max-width: 500px; width: 500px",
])

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 5, 2019

Ah, I see. You are right.

The view screen only shows the Issue Key. And when you open the edit screen again, the dropdown shows only the issue key.

This is not surprising because the database only stores the key in that text field. 

I think that's how it's designed to work. 

You could make a feature request/suggestion with Adaptavist to have that default behavior changed. 

The best I can offer as a suggestion is to have a different behavior script that looks for an existing value and then puts the summary for the linked issue in the field's description (below the dropdown).

This won't help with the view screen. The only workaround would be to have a scripted field that loads the linked issue details and display the issue key and summary. You would hide your linked issue field and display this calculated field on the view screen.

I hope this helps.

Gowri_Sankar November 5, 2019

Hi @Peter-Dave Sheehan ,

 

Thank you for your suggestion. I've populated both the key and the summary by writing a listener during the updating event to fetch the summary by using the key.

Suggest an answer

Log in or Sign up to answer