Hi, I have a choice component that shows the list of existing customers.
When the customer is new, I can press a button and add a new customer. What I am trying to achieve is that when I add a new customer, it becomes the default value of the choice component.
What I have done is fill a column in the users table and use it as the default value of the choice component. Oddly enough, months ago it worked. But now it doesn’t work anymore. I have tried several methods but none work.
I think if the underlying component isn’t refreshed after your attempt to add a new value to the list, then it won’t work. I assume you’re doing something like a form inside another form.
The behaviour might have changed recently based on your observation.
Ciao and thanks for your reply! Yes, it is a form inside another form. I have tried using a container form or an overlay form. Either way it adds the new client to the choice, but there is no way to make it the selected one. I will have to change my strategy
Just thinking out loud… Does is help if you add a custom collection and put a choice component inside it? As part of your flow that opens the form set the value of the choice component.
Add a single value to your user profile which targets the choice component.
Submit the choice component as a user profile column.
Is the source table for the choice component the same table that the primary form is writing to (main form that contains the choice component)? If so, I would just add a text entry component, point it to the same column that the choice component is writing to, and let the user choose between typing a name manually, or choose from the existing choices.
Thank you Jeff. Unfortunately they are not on the same table. In the main screen table I will store the RowId of the customer selected through the choice component. If the customer does not already exist, I want to be able to simply add it and then select it through the choice component. In order to get a better (and faster) interface, I would like the newly entered customer to be the one selected by default in the choice component.
Thanks Eric. I can’t figure out how to use a custom collection in this scenario. Sorry, maybe I just misunderstood your answer because of my English skills
What he meant can be executed like this:
- Add a column call “temp user” that is a user-specific column inside your Users table.
- Add a custom collection in your form that points to the Users table and filter by email is signed-in user, so you’re seeing your own row.
- Add a choice component to that custom collection, writing to “temp user”, with the list of available options being the list of users.
- When you add a new user in the form-inside-form, add an on-submit action to write the ID/email of that user to the user profile row > temp user column.
- In the parent form, add an on-submit action to set the “temp user” value to the “user” column in your destination table, and then clear the “temp user” column in your Users table to prepare for the next iteration.