Jul 22, 2020 04:41 AM
I want to be able to pick a value which and select some some other values which shows only values that contains values that includes values from first pick.
I’ve been trying to play around with options.fields however I’m a little unsure what to put in as a fields value. I’ve tried ID’s and name values but I’m getting an error: ‘No field matching’
let filterArr = []
let filter = await input.recordAsync('Select Sender', base.getTable('Contacts').getView('Mills'))
filterArr.push('rectBqFb8f8DtgRLW')
let selectRecord = await input.recordAsync(
'Select a record',
base.getTable(selectBase).getView(selectBaseView),
{
fields: filterArr,
shouldAllowCreatingRecord: false
}
)
what do I need to pass as fields value?
Solved! Go to Solution.
Jul 23, 2020 04:00 AM
Hi @Kim_Trager1 - Not sure if I totally get your setup, but this might help. My base has two tables - countries and cities. Country is a linked record in cities:
I then have this script:
let countriesTbl = base.getTable('Countries');
let citiesTbl = base.getTable('Cities');
// pick a country
let country = await input.recordAsync('Pick a country', countriesTbl);
// if there is a country
if (country) {
// show the chosen country
output.text(`You picked ${country.name}`)
let chosenCountry = country.name;
// query the cities table
let citiesQuery = await citiesTbl.selectRecordsAsync();
// filter the cities records so that only those matched to the chosen country are returned
let cityPicks = citiesQuery.records.filter(city => city.getCellValueAsString('Country') == chosenCountry)
// now pick a city based on the filtered set of cities
let cityPick = await input.recordAsync('Pick a city', cityPicks);
if(cityPick) {
output.text(`You picked ${cityPick.name}`);
}
}
So, I’m choosing a country, then filtering the cities based on the selected country. The result (the set of filtered cities) is passed to the second record selector and only displays the appropriate cities.
Does that work for what you’re trying to do?
Jul 23, 2020 04:00 AM
Hi @Kim_Trager1 - Not sure if I totally get your setup, but this might help. My base has two tables - countries and cities. Country is a linked record in cities:
I then have this script:
let countriesTbl = base.getTable('Countries');
let citiesTbl = base.getTable('Cities');
// pick a country
let country = await input.recordAsync('Pick a country', countriesTbl);
// if there is a country
if (country) {
// show the chosen country
output.text(`You picked ${country.name}`)
let chosenCountry = country.name;
// query the cities table
let citiesQuery = await citiesTbl.selectRecordsAsync();
// filter the cities records so that only those matched to the chosen country are returned
let cityPicks = citiesQuery.records.filter(city => city.getCellValueAsString('Country') == chosenCountry)
// now pick a city based on the filtered set of cities
let cityPick = await input.recordAsync('Pick a city', cityPicks);
if(cityPick) {
output.text(`You picked ${cityPick.name}`);
}
}
So, I’m choosing a country, then filtering the cities based on the selected country. The result (the set of filtered cities) is passed to the second record selector and only displays the appropriate cities.
Does that work for what you’re trying to do?
Jul 24, 2020 07:14 AM
Thats exactly it. Thank you