[2nd Option] Filter a Select Field by Another Select Field

🔀 Tailor a selected field based on another selected field the other way around.

1. Overview

This Interaction also filters a particular field by another defined field, but the other way around.

2. Example

This example illustrates how we can filter primary contacts based on the organisation. It returns only those primary contacts that are part of a particular organisation based on the organisationId.

async function handler(C) {
    const organisation = C.getValue("organisation");
    if (organisation && organisation.length > 0) {
        const organisationId = organisation[0];
        const filter = C.setFilters("primary-contact", [
            {
                subject: "client",
                requestType: "i",
                type: "array",
                operator: "any_of",
                value: [organisationId],
            },
        ]);
        return filter;
    } else {
        return C.setValue("primary-contact", []);
    }
}

📌 Need Help?

If you require assistance or encounter any issues, please don't hesitate to contact us for further support.