Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to use "select list conversion" with Script Runner Behaviour in Service Desk

Yves Martin
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.
February 6, 2018

 Hello

I have successfully applied Script Runner select list conversion to text custom fields in JIRA and try to add same behaviour when field is available at Service Desk request creation from customer portal.

First, is "select list conversion" available in Customer Portal ? and if so, may you please provide a specific example how to get it work.

For information, my versions: JIRA 7.7.1, ServiceDesk 3.10.1 and Adaptavist Script Runner 5.3.1

The initialiser I use and works well in JIRA screens. In JIRA ServiceDesk, select list is empty and typing has no effect:

getFieldByName("Substitute Manager").convertToSingleSelect([
    ajaxOptions: [
        url : getBaseUrl() + "/rest/scriptrunner/latest/custom/substituteManager",
        query: true,
        formatResponse: "general"
    ]
])

Thank you in advance for your help

Yves

2 answers

Suggest an answer

Log in or Sign up to answer
1 vote
Yves Martin
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.
February 15, 2018

According to web console, it looks like jQuery loading may be lacking:

https://productsupport.adaptavist.com/browse/SRJIRA-2667

Have you got any idea how to work-around this failure ?

Yves Martin
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.
March 7, 2018

As a work-around, I have replaced "select list conversion" by Customer Portal field value validation against database thanks to "Behaviours"...

Lulzim Bulica April 13, 2018

Hello, i am facing the same problem, the conversion is not accomplished in the Customer Portal, did you find a solution?
Thank you

Yves Martin
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.
April 13, 2018

As a work-around, I have replaced "select list conversion" by text field value validation thanks to Behaviours which connects directly to database (so rest service is no longer used).

Behaviour scripts provide available options for each field with setDescription (if list is short) and reports validation error with setError (and clearError)

To notice, there is a drawback to get behaviour scripts to run properly: it is required that customer users have "Browse Project" permission !

Hope this helps

Lulzim Bulica April 13, 2018

Thank you very much for your answer.

I am new in Jira and i do not fully understand the answer. Do you mean you do not convert the text field in select field anymore? 
What i need to do is create a "Project Picker" select customfield. As the Project Picker customfield type is not supported by Jira Service Desk i am trying to implement a drop down with project names. Is it possible to share your behaviour code, i would really appreciate it. 
Thank you

Yves Martin
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.
April 13, 2018

You understand well I no longer convert text field into select field.

I wrote behaviour to validate field value - in my case user account names against a database

In your case, I wonder if customer users may be able to fill JIRA project key in text field, so that you just have to validate it against jira project manager service... It really depends on your JIRA project keys complexity/length/memory-friendly.

I am sorry but I have no code close enough to your use case which is worth to share

Regards

Yves Martin
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.
April 13, 2018

Please vote for Adaptavist issue...

0 votes
Shruti Chauhan November 28, 2019

Hi @Yves Martin ,

I am trying to apply Script Runner select list conversion to select box custom fields in JIRA using below steps -

Added behaviour and add below script in initializer -

getFieldByName("selectTecId").convertToSingleSelect([ //selectTecId is the id of combobox
ajaxOptions: [
url : getBaseUrl() + "/rest/scriptrunner-jira/latest/issue/picker",
query: true,

data: [
currentJql : "project = TIM ORDER BY key ASC", // TIM is the key of project.
label : "Pick high priority issue in Support project",
showSubTasks: false,
],
formatResponse: "issue"
],

])

but I am unable to apply it successfully as I have no idea how 'selectTecId' recognize by behaviour.

I am trying to achieve below -
Added custom button in Jira using Scriptrunner.
On button click, a pop-up will appear and need to add a autoselect pop-up list.
For this, I need to add behaviour but stuck with the above problem.

Could you please help me with this.

TAGS
AUG Leaders

Atlassian Community Events