0
votes

I am running into an issue where I have 3 SQL Datasources (Employee, Course, Overview).

I have created a page inherited from the Overview Datasource, where i have created a drop down (options based on the Employee Datasource Employee.items.Name._equals, value set to Overview.Item.Name). When i select his name in the drop down, I want to dynamically fill in a text field where it selects the email field from the Employee Datasource based on the person selection in the drop-down.

Is this possible? If so, how do I proceed? If further information is required please feel free to ask.

1
Typically for a dropdown when bound to datasource.items you should just be able to set your function in the onValueEdit event or onValueChange event of your dropdown and then set your textbox value by doing widget.root.descendants.YourTextbox.value = newValue.Email. However I'm not sure if that would work with your setup or not. Might be helpful to explain more details if that doesn't work for you. - Markus Malessa
i'm not sure how i can get the newValue.Email . I've entered the following custom action to the drop down (which is inherited from the Overview Datasource). options --> datasources.Employee.items.Name value --> datasource.item.Name onValueChange --> var newValue = app.datasources.Employee.query.filters.Naam._equals = widget.text; var record = app.datasources.Employee.load(); widget.root.descendants.EmailTextBox.value = record.Email; but this doesn't work. what am I doing wrong? - PeterVG
Does your onValueChange code not give you an error? You have var newValue = 'something' = 'somethingelse'; (this should throw an error in your code). Also, setting the newValue equal to a query doesn't seem quiet right and widget.text points to your dropdown label, not the value. I am working with a Drive Table example still, but that shouldn't change any of the basic behavior compared to a SQL datasource. The last possible issue might be that var record is a load action not a datasource item. Let me provide an answer with code and try and see if that works for you. - Markus Malessa

1 Answers

0
votes

Based on your comment change the following items around.

Overview Datasource dropdown options:

@datasources.Employee.items

Leave your dropdown value the same for now.

Dropdown onValueChange event:

widget.root.descendants.EmailTextBox.value = newValue.Email;

Observe that the newValue is a built in variable in the widgets API for a dropdown and points to an object of the options datasource, therefore, if your options are @datasources.Employee.items the options are an array of objects that make up all the Employee items and when selecting one option it points to items[index] and then you are able to call your object at index with the name of your object item. So newValue.Email should get the selected Employee email.