How to : Preselect the right option in a dropdown menu build via API while editing?

Hi, it’s me again,

Hit a new wall, in a popup I use to edit a repeating group’s entry, I have a dropdown menu, built from an API call. The list of options displays well, but the value=“” in the code is weird and I can’t find how to define what I want in the value, and more importantly, in the (almost same) edit popup, I want to pre-select the choosen option for the current row.

The rows are users, and the dropdown menu is the subscription plan.

This is how the dropdown is built :

The plans API sends a list of plans with IDs and name, but I only found where to use the name ( option caption) but not the value.

And then during the edit :

I would want that dropdrown to select the correct plan of the user automatically, by using the ID’s from the plans api call, and subscription_plan_id from parent’s group get results …

Any idea how I could do that ?

Mehdi

i cannot tell from your screen shot but you’ll need to select an item in the array from your end point… item #

select an item where ?
what screenshot would help explain this better ?

I’m using a workflow to “show popup” > “display data” to pass the current row’s data to the popup.

the default value as it stands looks like its returning a list… click the (more) item# or try first item

1 Like

Yes the default value is wrong, i tried many combination to no avail.

I don’t get the item# you’re referring to :confused:

Flying blind here… Is always best to share a link with your editor so people can see what you’re doing. Your choices sources obviously a list based on an API response right? If that’s the case then the default choice you trying to make is obviously some sort of numeric field defined in your API response as numeric correct

1 Like

I’d love to but it’s connected to the admin API of our product :frowning:

I tried sending you a PM but even that it says i’ve now created too many topic for a new member … I will try tomorrow if you don’t mind!

In any case I really appreciate you trying to help! :pray:

Best,

Dont worry about PM… Keep in the forum and it helps others. Let me put this another way… The default choice you wish to make I assume is a specific subscription_plan ID? From an array based on the API GET

Your pulling your API list based on ‘Parent group get-users results member organisations subscription_plan ID’ have you tried filtering these results with a constraint specific to the default choice you wish to make. If I’m stating the obvious just say

This is an edit popup so yes I want the “default choice” meaning the option in the dropdown menu to be selected when :

dcapi - plan-gets results (itemX) ID = ‘Parent group get-users results member organisations subscription_plan ID’

dcapi - plan gets results are the results of an api call that sends the list of subscriptions plans yes.

I’m not sure how to do contraints, and what’s driving me crazy is that I think I see how to do it, but when i try it doesn’t give me the right options (item #) where i need it …

May be this is stupid but do you think there’s something wrong in the value="" of the dropdown ? from the second screenshot i posted (the chrome console) it seems weird that value="" has all that weird json code instead of a simple subscription plan id…

Mehdi

Was this ever solved? I have the same situation… trying to get my edit dropdown populated from the api call associated with repeating group?