Possible to filter out certain records in a input.recordAsync()

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?

Hi @Kim_Trager - 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?

2 Likes

Thats exactly it. Thank you

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.