JIRA call to external web service to return list of values to populate field

Stephen Marsh November 20, 2017

Is it possible to configure a JIRA custom field to show a list of selectable options which are populated by a call to external web service using Scriptrunner?  I am basically looking to make a call to a SOA rest api which will return a list for the user to select from. This will then in turn populate my custom field... I am new to Groovy so any examples would be appreciated. Thanks :-) 

1 answer

0 votes
Aidan Derossett _Adaptavist_
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.
November 22, 2017

Hey Stephen! 

If I'm understanding you correctly, then I believe you could accomplish this with a Behaviour and a select list conversion. We have some examples and further documentation on the process here.

Let me know if that looks like it'll work for you or if you have any questions! :D

Best,

Aidan

Stephen Marsh December 5, 2017

reply to follow

Stephen Marsh December 7, 2017

Hi Aidan, thank you for your response...I have tried this script and manipulated it to my URL etc but i am seeing a couple of errors... the first errors tell me that the uri.path, headers and response.failures variables are undeclared... Am i missing part of the script? any guidance appreciated, thanks

adammarkham
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.
December 11, 2017

Hi Stephen,

I think these are just static type checking errors. Does it work if you save it and run it?

Thanks,
Adam

Stephen Marsh December 12, 2017

Hi Adam, thanks for coming back...

i have been looking at a simpler alternative... is it possible with a behaviour to restrict the values that are allowed in a custom field?

I have a single line text field but i would like to create a behaviour that will restrict what values could be saved in the field and return an error if an incorrect value was input and a save attempted? I was wondering whether i could create a behaviour to do this?>

i am aware that i could create a new field of the select list type but i was hoping i might be able to lock my single line text field down with a behaviour?

thanks :)

adammarkham
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.
December 12, 2017

You could use a behaviour to do this. Unfortunately populating the list dynamically is not a good fit for behaviours.

If your getting the values from a REST API your really best off using the select list conversions part of behaviours.

If your no longer doing this and have a text field. You can of course check the content using a behaviour and then setting an error if it's not allowed. 

There are many examples online and recipes here to get you started.

Hope this helps.

Adam

Stephen Marsh December 12, 2017

Thanks Adam - I have already been trying to find a similar example on the Scriptrunner site and wider internet but havent come across a specific one that validates the value being input into a field but ill keep digging.

Thanks.

Stephen

Suggest an answer

Log in or Sign up to answer