👯 Filter multiple selected fields based on another field.
1. Overview
This Interaction enables you to filter multiple selected fields by another defined field.
2. Example
In this example, the function filters the opportunity and main-contact fields to only show the opportunities and contacts associated with the selected customer (defined by customerId), respectively. The two filtered fields have the same internalId for the selected parent field Customer, which is customer, the requestType: "i" is removed, thus, the fieldId is used.
async function handler(clev) {
let actions = [];
const customer = clev.getValue("customer");
if (customer && customer.length > 0) {
const customerId = customer[0];
actions.push(
clev.setFilters("opportunity", [
{
subject: "3095", // "customer"
type: "array",
operator: "any_of",
value: [customerId],
},
])
);
actions.push(
clev.setFilters("main-contact", [
{
subject: "1727", // "customer"
type: "array",
operator: "any_of",
value: [customerId],
},
])
);
return clev.mergeAll(actions);
} else {
actions.push(clev.setValue("opportunity", []));
actions.push(clev.setValue("main-contact", []));
}
return clev.mergeAll(actions);
}📌 Need Help?
