Unable to set default value in executor select based on other select inputs and query result

1) My goal:
I have three select components: one for customers (select_request_customer_add), one for objects (select_request_object) which loads objects of selected customer, and one for work types (select_request_work_type). Based on selected object and work type, i query assignments (table assignments) to get executor_id, which should automatically populate as default in the main_executor_add select (that loads data from users table filtered by role = 'executor').

2) Issue:
Query get_executor_for_assignment returns correct executor_id (and even executor_name joined from users). But setting default value in main_executor_add select using this value does not work. The select remains empty with placeholder.

3) Steps I've taken to troubleshoot:

  • Verified that get_executor_for_assignment returns valid uuid matching id in users table.
  • Verified types (all uuid).
  • Tried using state variable and direct query result in Default value field of select.
  • Verified component names, ids, data source mappings (value mapped to item._id, label mapped to item.name).
  • Tried using control component action in query success handler.

4) Additional info:

  • Executors list comes from get_executors query (SELECT id, name FROM users WHERE role = 'executor').
  • I also need to retain possibility to manually select another executor, but default should populate automatically based on assignment matching selected object + work type.

I need help, how exactly to set default value or force select to pick item by id using query result or variable.

Hi @trpchp, welcome to the Retool Community!

You can set a default value for your main_executor_add_select component by following these steps:

  1. Add a Success event handler to the query you're running.
  • After the query runs successfully, add an event handler of type "Control component".
  • Choose the main_executor_add_select component.
  • Set the method to "Set value".
  • In the value field, enter the data you want to set as the default value.
  1. Enable custom values in the select component:
  • Select the main_executor_add_select component.
  • In the Inspector panel on the right, go to the Interaction section.
  • Click the three dots () next to the interaction to open Advanced Interaction.
  • Turn on the option "Allow custom values if value not in the option list".

Following these steps will let you set a default value in your select component, even if that value isn't already in the options list.

Feel free to ask if you need further assistance or have additional questions. We're here to help!