✌️ Tailor a selected field based on another selected field easily.
1. Overview
This Interaction filters a particular field by another defined field. This configuration clears out the filtered field when a different parent entry is selected. In this way, the old filtered field value is emptied, and the new list is loaded, preventing the old value from being left and forcing the user to select a new one.
2. Examples
Refer to the examples below:
2.1. Example 1
This function filters out the data based on the 1662670-project within the 1662670-task. It returns all those 1662670-task tasks associated with the 1662670-project project.
async function handler(C) {
let actions = [];
const project = C.getValue("1662670-project");
if (project && project.length > 0) {
actions.push(
C.setFilters("1662670-task", [
{
subject: "1662670-project",
requestType: "i",
type: "array",
operator: "any_of",
value: [project[0]],
},
])
);
actions.push(C.setValue("1662670-task", []));
} else {
actions.push(C.setValue("1662670-task", []));
}
return C.mergeAll(actions);
}2.2. Example 2
The following example demonstrates that when a customer is chosen within the opportunity field, the function returns only those opportunities that are associated with the defined customer.
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: "customer",
requestType: "i",
type: "array",
operator: "any_of",
value: [customerId],
},
])
);
return clev.mergeAll(actions);
} else {
return clev.setValue("opportunity", []);
}
}📌 Need Help?
