Show entry in dynamic dropdown without using the 'selected value' field

I have a dynamic dropdown in a modal to let the user select some let’s say categories, using an ‘add’ button next to it in case the desired category is not yet listed which then should automatically be selected. Adding a new category and getting the identity value back from the query works fine, but:

I’d like to set the dropdown to the new entered value and I’m struggling there. When using the ‘selected value’, it works but all new entries from this point on use the identity value by default instead of blank. When I try to set the value of the select using dynamic behaviours without using the dynamic behaviour, nothing happens.

Hi,

Looks like you need to make use of success event of adding new category to get the identity of newlg added category.
Then reload the category SC, that is bound to dropdown, and then on success event of that, check if there is any value to be selected, and set it as value of dropdown.

Hi sid, that’s exactly what I did, but when the user is done using the procedure (it runs in a modal by itself) and wants to add a new item, the newly inserted category remains selected (instead of the default ‘?’).
Is there maybe a way to clear the new_id value? Or any other idea without reloading the page?

Is there any way to clear the new_id value (as described here Retrieve record ID after insert) after using it to set the selected value of the dropdown? That would solve my problem

Instead of binding drop down with the server connect data, bind it with a variable.
On success of said SC, set value of variable as inserted id.
And, on click of add button, just remove the value from variable sonothing will be auto selected at that time.

Ok I was thinking of that too (just with a hidden textfield instead of the variable)

but then I would need two select fields, right? One without seleted id to start with and one with selected:new_id after a new category has been inserted, and hide the one which is not used, right?

No. A single select should work fine.
Just set the dmx-bind:value="varNewInsert.value". When the variable value is null or empty, nothing will be selected in the dropdown. And when there is value, that will be selected.

1 Like

Perfect. Thank you!