I have been using the below code for a year and it worked as expected since the update I have to refresh the screen before the filter will apply and also the filter does not update on change.
Can you please help?
// getting the selected Choice (0 if nothing is selected).
var choice = v;
var today = new Date();
//number of ms in a day:
var day = 86400000;
//amount of days:
var amountOfDays = 21;
//get date to filter with:
var filterValue = today - (day * amountOfDays);
var filterDate = new Date(filterValue);
// setting filtration
fd.field('Race').filter = "Title eq '" + choice + "' and StartDate gt datetime'" + filterDate.toISOString() + "'";
fd.field('Car').filter = "Series eq '" + choice + "'";
fd.field('CrewName').filter = "IsPitCrew eq 'Yes'";
fd.field('CrewName2').filter = "IsPitCrew eq 'Yes'";
fd.field('CrewName3').filter = "IsPitCrew eq 'Yes'";
fd.field('CrewName4').filter = "IsPitCrew eq 'Yes'";
fd.field('CrewName5').filter = "IsPitCrew eq 'Yes'";
fd.field('CrewName6').filter = "IsPitCrew eq 'Yes'";
fd.field('CrewName7').filter = "IsPitCrew eq 'Yes'";
fd.field('CrewName8').filter = "IsPitCrew eq 'Yes'";
fd.field('CrewName9').filter = "IsPitCrew eq 'Yes'";
fd.field('CrewName10').filter = "IsPitCrew eq 'Yes'";
//filter when form opens
//filter when Choice changes
fd.field('Race').value = null;
The code seems fine, please follow these steps:
- Reopen the Forms client (the new version will be installed)
- Check for the errors in the browser console. If you have any, please send a screenshot.
- Clean the browser cache completely
Below is the console error.
Most probably, the issue is the lookup fields are not ready at the moment the filtering is applied, that’s why the error “Cannot set property “filter” of undefined” appeared.
After some debugging I have discovered that the issue is fd.field(‘Race’).widget.dataSource.read(); is null, So your stating using “ready” makes sense however the documentation refers to using two look up. In my case Series is a choice and only
Race is a lookup. When I attempted to put the ready on Race it stated that ready was not a function. Could you please help clarify this.
fd.field(‘Race’).widget is null by the same cause - the field is not ready yet, you should wrap this code in the “ready” event handler like in the example in the documentation: https://plumsail.com/docs/forms-sp/how-to/lookup-cascading.html#description
after getting the ready function working. We still had issues we discoved that the select statement on the look up is doing a select of “Series” which does not exist in the lookup column.
I do not need that column to exist. I realized this was coming from the extra fields area when I removed it. I changed that to pull back Title/Id but now filter does not apply unless you do a screen refresh…even if you change the series.
Could you please provide the screenshot of the browser console? It seems that there is an error during filtering.
This form was being used so I had to resolve this issues quickly I removed the Title filter from the form for now. I will post the information on the other form which is in development shortly.
I am trying to get this to function correctly I have the below code
var whatIsTheFilter = field.filter;
var isThisNull = fd.field('Race').widget;
console.log("isWidgetNull " + isThisNull === null);
The console looks like