Cascading Lookup Issue

I've got a cascading lookup filter on a form that hasn't changed in over a year. Last week I noticed it not working as expected. When I watch console I see it's not applying the correct 'current' filter, it's always one behind if that makes any sense.

To isolate the issue I replaced my code with your Category->Product example code, just changed the two field names to mine but it's still the same behavior. Imagine a new form with your example, change Category to Cell Phones then see Product is the full unfiltered list. Then change Category to Cameras and see Product is filtered for Cell Phones. Change it to TV and Products is filtered for Cameras! It's always applying the filter for the last Category value, not the current one. But when I print the categoryId to console it's always showing the correct current value, but the OData query isn't using that value.

I figured this was general SharePoint tenant weirdness, thinking it would resolve itself after a few days but no such luck. For now I had to comment out the filter. Any ideas?

Hello @Bjorn,

Are you using SharePoint Online?

If so, please make sure you are using the latest version of the app package, which is 1.0.8. You can find the instructions on how to Update the app package here.

After the update, you might need to re-save the form using the latest version of the designer (1.7.1).

if the app package update did not solve the issue, please share the screenshot of the form and the errors in the browser console(F12).

Hi @mnikitina.

Yes, SharePoint Online and latest versions of the app and designer. There are no errors in console, it's just not applying the filter correctly. But I've got a workaround now (should have tried this before posting). I just call the dataSource.read() twice and now it works again. It feels like an asynchronous issue, but if nobody else is reporting this then it sounds like one-off SharePoint tenant weirdness to me!

2020-07-13_12-19-24

Hello @Bjorn,

Please try to add the refresh function instead of the second dataSource.read(), like this:

fd.field('Series').widget.dataSource.read();
fd.field('Series').widget.refresh();

Is the filter applied using this approach?

Nope, that didn't work for me, same issue as before. I changed back to read() x2 and the filter is correctly applied.

Hello @Bjorn,

Ok, I reproduced the case on my tenant.

Thank you for reporting this! Seems like this is an issue on our side, I passed the information about it to our developers.

I will let you know as soon as I get a reply from them.

1 Like

Hello @Bjorn,

We published a fix. Please replace both fd.field('Series').widget.dataSource.read(); with fd.field('Series').refresh() like this:

function filterProducts(category) {
    var categoryId = category && category.LookupId || category || null;
    fd.field('Product').filter = 'Category/Id eq ' + categoryId;
    fd.field('Product').refresh();
}

Thanks @mnikitina, that did the trick!

1 Like