javascripterppriority-web-sdk

Priority-Web-SDK: Filtering a form


I am trying to understand how to use the setSearchFilter function in the Priority Web SDK. I can run formStart() followed by form.getRows(1) to get the entire form, but I only need ~5 of the over 100 rows.

login(configuration)
    .then(() => formStart('ORDERS', null, null, 'demo',1))
    .then(form => form.setSearchFilter({
        or: 0,
        ignorecase: 1,
        QueryValues: [{
            field: 'TOTPRICE',
            fromval: '100',
            op: '>'
        }]
    }))
    .then(filter => filter.getRows(1))
    .then(rows => console.log(rows))
    .catch(err => console.log(err));

If I comment out the then-setSearchFilter line, I get the entire form. With it in, I get filter undefined.

This is for a phone app so how much data I download seems important.


Solution

  • As you can see in the documentation setSearchFilter doesn't return a filter object. After defining the filter each call to getRows will return rows according to the filter. You should call it like this: form.getRows not filter.getRows.

    In addition, when defining a Filter you must define all of its members.