Discussion posts and replies are publicly visible
Thank you for your reply, Josh. I do configure a placeholderLabel for the dropdown box and there is data in the entity.
1. Here is the complete code for the dropdown field:
a!dropdownField( label: "Supervisor", labelPosition: "ADJACENT", placeHolderLabel: "--- Select One ---", choiceLabels: index(local!newEmployee.firstName, where(local!newEmployee.isSupervisor)), choiceValues: index(local!newEmployee.firstName, where(local!newEmployee.isSupervisor)), saveInto: { local!newEmployee.supervisor }, refreshAfter: "UNFOCUS", validations: {} )
I believe this configuration gives and error saying that the value is null. I can't verify at the moment because I have an unrelated DB issue I have to fix later today.
This interface is also configured with a!writeToDataStoreEntity(), so when I don't get an error, for example, if I just configure this field as a textField, then it saves and updates the data store successfully.
2. I will try those suggestions when I can. Thank you.
Hi Fred, You need to specify the "value" attribute for the dropdownField. It would probably look like "value: local!newEmployee.supervisor" or "value: index(local!newEmployee, "supervisor", null)" if you want to be a little bit more safe. Using dot notation (local!newEmployee.supervisor) will break if the supervisor field can't be found. index(local!newEmployee, "supervisor", null) will return null (the third parameter) if the supervisor field can't be found. Note: The dot notation must be used in the saveInto attribute.
It was giving me the same error about isSupervisor passing a null variable, but after tinkering with it for a day, I've gotten a little bit closer:
load( with( local!employeeDS: a!queryEntity( cons!FSRC_EMPLOYEES_ENTITY, a!query( selection: a!querySelection( columns: { a!queryColumn( field: "firstName" ), a!queryColumn( field: "lastName" ) } ), filter: a!queryFilter( field: "isSupervisor", operator: "=", value: true ), pagingInfo: topaginginfo( 1, - 1 ) ) ), a!dropdownField( label: "test", placeholderLabel: "--- test ---", choiceLabels: local!employeeDS.data, choiceValues: local!employeeDS.data, saveInto: {} ) ) )
The output I get in the dropdown is [firstName:Bill,lastName:Smith]
Almost there, but formatting seems to be the issue now.
Try something like this, replacing "yourIdFieldHere" with the pk of your table.
load( local!supervisorId, with( local!employeeDS: a!queryEntity( cons!FSRC_EMPLOYEES_ENTITY, a!query( selection: a!querySelection( columns: { a!queryColumn( field: "firstName" ), a!queryColumn( field: "lastName" ), a!queryColumn( field: "yourIdFieldHere" ) } ), filter: a!queryFilter( field: "isSupervisor", operator: "=", value: true ), pagingInfo: topaginginfo( 1, - 1 ) ) ), a!dropdownField( label: "test", placeholderLabel: "--- test ---", choiceLabels: apply( concat(_, " ", _), merge( index(local!employeeDS.data, "firstName", {}), index(local!employeeDS.data, "lastName", {}) ) ), choiceValues: index(local!employeeDS.data, "yourIdFieldHere", {}), value: local!supervisorId, saveInto: local!supervisorId ) ) )