Aug 16, 2021 11:51 AM
My application has several Select components which the user can use to enter information. The first two fields have only a small number of options. The third field has over 70 options and can be tedious to use.
I want to use the values selected in the first two Select components to filter the available options presented to the user in the third Select.
The options in the third select are pulled from records in the base. These records have linked fields. Some of these linked field values are options chosen in the previous Select components.
So, lets say I want to filter returned records from a table where values in a linked field (s) match either the record ID of string value in said linked field.
Aug 16, 2021 01:17 PM
const thirdSelectFieldsOptions = records
.filter(record => record.getCellValue(linkRecordFieldId).map(val => val.id).join("") === secondSelectFieldValue)
.map(record => {value: record.id, label: record.name})
^ something like that.
Aug 16, 2021 04:41 PM
Thanks @Kamille_Parks . When I attempt to call records.filter I get the following error :
maintenanceProcedureNameRecords.filter is not a function
I tried writing maintenanceProcedureNameRecords as an array, and got a little bit further. SO i have something like this.
function ProcedureSelect ({systemId},maintenanceProcedureNameRecords,setProcedureId,procedureId){
const newbase=useBase()
let tableMaintenanceTasks=newbase.getTableByNameIfExists('Maintenance Tasks')
if(!systemId){
return null
}else{
const linkRecordFieldId=tableMaintenanceTasks.getFieldByNameIfExists('Top Level System');
const filteredProcedureOptions = [maintenanceProcedureNameRecords].filter(record => (record.getCellValue(linkRecordFieldId).map(val => val.id).join("") === systemId.value)).map(record => ({value: record.id, label: record.name}))
return (
<Select
onChange={setProcedureId}
options={filteredProcedureOptions}
value={procedureId}
/>
)
Executing this gets me the following error:
TypeError: record.getCellValue is not a function
It seems like there has to be something simple/fundamental that I am missing here.