function on_field_select_value(field, lookup_item) {
// Define which fields should trigger this filter
const target_fields = ['album', 'genre'];
if (target_fields.includes(field.field_name) && field.value) {
lookup_item.set_where({ id__eq: field.value });
}
}
This function is assuming that the ID field exists for album and genre,
and then locates the record. So it is not displaying all records, but a single one.
When we have a different ID, which is absolutely possible:
function on_field_select_value(field, lookup_item) {
const field_map = {
album: 'id',
genre: 'genreid',
artist: 'artist_id'
};
const target_field = field_map[field.field_name];
if (target_field && field.value) {
const where = {};
where[target_field + '__eq'] = field.value;
lookup_item.set_where(where);
}
}