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.
Did you test out the above suggestions steps to see if they work?
It sounds like you are doing everything right, the issue is that 'default' value is read at page load, so it won't every be a value that can be set by queries that need to run based on component's being set. As all those events happen after the page load events occur.
For this reason, you should instead of setting the default value, just set the value of the select component to be the data that you want from your various queries once they succeed.
The 'default' value is meant to be a hard coded constant that does not change, and thus it can't really be dynamically re-assigned. But you can set the data source of the component to be a variable that contains the executor data that you are defining based on the other selects and queries.
And then you can re-assign source variable when anything changes or re-assign the component's value. Just depends on if you want to use a variable as the source of truth or use the 'Method-Set Value' events from the control component panel.