Reverse Filter

⬅️ Filter a selected field based on another but in reverse.

1. Overview

This Interaction enables you to filter a specific field by another field, but in reverse order.

2. Example

In the below example, the function filters an organisation based on the primary-contact selected, i.e., it will return all those organisations associated with the defined primary contact.

async function handler(C) {
    const primaryContact = C.getValue("primary-contact");
    if (primaryContact && primaryContact.length > 0) {
        const entry = await C.api.getEntry({
            id: primaryContact,
            responseType: "iov",
            recordId: 464250,
        });
        let clientId;
        try {
            clientId = JSON.parse(entry["client"])[0];
        } catch {}
        if (clientId) {
            return C.mergeAll(
                C.setValue("organisation", [clientId]),
                C.setFilters("organisation", [
                    {
                        subject: "id",
                        type: "number:recordValue",
                        operator: "equals",
                        value: clientId,
                    },
                ]),
                C.setFilters("primary-contact", [
                    {
                        subject: "client",
                        requestType: "i",
                        type: "array",
                        operator: "any_of",
                        value: [clientId],
                    },
                ])
            );
        }
    }
    return C.mergeAll(
        C.setValue("organisation", []),
        C.setFilters("organisation", []),
        C.setFilters("primary-contact", [])
    );
}

📌 Need Help?

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