Auto update a value in one component based one user selection in another component

Hi there I want to use an eventhandler to auto update the value in component B named customer_region (A gets data from my customerDB eg cell customer_region), based on the selection in component A customer_name ( gets data my customerDB eg. celle customer_name. How is this done? I have a simple qurey that match customer_name and customer_ region.

retool

Thanks

Use a change Event handler for A that will then set the value for B using bFieldName.setValue('newValue')

Hey ScottR,

Can you provide an example?

In the inspect panel for the select component A, add an Event Handler that will run a query on Change


When that query is complete you should add an Event handler in Succcess for Control Component and set the value from the query you just ran.
Screenshot 2023-09-13 at 3.11.37 PM

1 Like

Hey ScottR,

I am not sure how the "set value" statement should look.

I am not sure how to use the xxxx.setValue('newValue') could you provide an example.

/Thanks

yourFieldName.setValue('somevalueherethatyouwantset')

They value, that I want to set have to come from my query. eg. I have query that joins my customer tabel eg. customer_name with a tabel of possible municipalities eg. customer_municipality, I want to show the customer_municipality as the value in fieldB

/Thanks

yourFieldName.setValue(yourQuery.data.customer_municipality)

Though I don't know what yourQuery.data looks like

Here is an example :blush:

So, for customer municipality field you can simply add
{{getDataCustomerMunicByCustomeName.data.customer_municipality}} as the source.


/ Thanks

This one:
Screenshot 2023-09-22 at 2.55.39 PM

For Value put in {{item.customer_municipality}}
For Label put in {{item.customer_municipality}}

Great :blush: and where to put {{getDataCustomerMunicByCustomeName.data.customer_municipality}}?

Just use the query name.data as the source and then add item as noted above