Can anyone help with this?:
I have two datasets, Policies, and Clients. There is a referenced field in Policies called “client” which points to Clients.
I have this piece of code:
let id_of_selected_option = “40b517f2-6732-4ecc-a0a9-266715117f69”;
wixData.query(‘Policies’)
.include(“client”)
.eq(“client”, id_of_selected_option)
.find()
.then((results) => {
console.log(results.items);
}
)
This works.
However, rather than defining the id_of_selection_options as a variable, I would like it to be set from the selected option of a dropdown instead. My dropdown is connected to the Policies dataset, with both the “Values connected to” and the “Labels and values connected to” options set to “Policy number (Text) field”.
How do I do this? I can access my dropdown using $w(‘#dropdown2’).options but I can only work out how to get the value or label from this, not the id of the selected option. How can I do this, order to get the result I am looking for?