Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Conditional convertToSingleSelect based on REST API response i.e free text when NULL response

I am using "convertToSingleSelect" to convert custom text field to drop-down . I want to make it conditional i.e 

a) Select dropdown when response is not NULL

b) Free text when response is NULL .

1 answer

1 accepted

0 votes
Answer accepted

To do that, you would have to have to make your rest call twice, once to pre-validate if there is any response, and if so, then make the conversion with the ajaxOptions.

Alternatively, don't use the ajaxOptions, make your rest request, verify the response is not null then convert to single select with setFieldOptions


def httpBuilder = new HTTPBuilder(urlOfYourDataSource)
def responseData
httpBuilder.request(Method.GET, ContentType.JSON) {
response.success = {resp, data ->
responseData = data
response.failure = {resp, text ->
log.error "Error: $text"
//you may need to transform you data to get a map of id and values for the select
def map = someFunctionToTransformYourResponse(responseData)
def textFld = getFieldByName("textFieldToConvert")

Note that with this approach, you can't repeat the request with each keyPress.
But the typeAhead search/filtering will still work on the full data set.

Thanks for your quick response .

I have thought about this approach but it was taking two API calls that's where I stuck .

I want to make this in single API call other wise we can prepare drop-down using jQuery.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

☕️ Monday coffee with Jexo: Weekly Atlassian news roundup | 21st June 2021

Hi community 👋, as every Monday we're bringing you a quick update on what happened in the Atlassian ecosystem last week. There were a few interesting events like for example the announcement of th...

47 views 0 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you