Filter lookup based on Date

Hi Everyone,

I'm looking to filter a lookup value based on "StartDate" and "EndDate" column field which is present in the lookup object . I attempted to achieve this through the following handler code, where I compare the current date with the End Date. However, it didn't work. Does anyone know of a better approach to filter the lookup value?

Below is my handler code:

{

    request: "crt.LoadDataRequest",

    handler: async (request, next) => {

        // filter the contact lookup for the account

                     

        if (request.dataSourceName !== "LookupAttribute_jw8dbjp_List_DS") {

            return await next?.handle(request);

        }

        // Add filter for UsrEndDate not less than the current date

        const currentDate = new Date();

        const filter = new sdk.FilterGroup(sdk.ComparisonType.And);

        filter.addItem(sdk.Filter.createColumnFilterWithParameter(

            "UsrEndDate",

            sdk.ComparisonType.GreaterThanOrEqual,

            currentDate

        ));

        request.parameters.push({

            type: "filter",

            value: filter

        });

        return await next?.handle(request);

    }

}

Like 0

Like

1 comments

Hello,

Take a look at this discussion, in there you can find an example of how to configure and add a needed filter.

In order to get the exact filter you need, use the test list method described there.

Show all comments