In SPO list why would FilterFieldX/FilterValueX work while FilterName/FilterMultiValue is ignored?
-
08-02-2021 - |
Pregunta
I am using a custom list with standard OOB AllItems.aspx view using the modern experience. (NOT a web-part, NOT the classic experience)
When I filter using
.../AllItems.aspx?FilterField1=MyTextColumn&FilterValue1=MyVal
it works fine and I see only rows containing MyVal.
When I filter using
.../AllItems.aspx?FilterName=MyTextColumn&FilterMultiValue=MyVal
or
.../AllItems.aspx?FilterName=MyTextColumn&FilterMultiValue=MyVal;YourVal
The list view acts as if no filtering was applied - all rows are displayed.
Ultimately the column I want to select on is "Single Line of Text" but I have gotten the same results using "Choice" and "Person or Group" and "Yes/No" as well. They work fine with FilterField1/FilterValue and they ignore FilterName/FilterMultiValue.
- Is there some special configuration I have to do for SPO to allow for filtering by multi-values?
- Is this a feature that works only with list web-parts and not with standard list views?
- Is this a feature that is no longer supported? (Most of the references I've read are from 2010-2014)...
- Am I mistaken in my understanding of how this should work? Should I be able to directly replace FilterField1/FilterValue1 with FilterName/FilterMultiValue and have it work identically?
I have checked about 20 times to make sure I have correct case and spelling on FilterName/FilterMultiValue and I have even tried (as I've seen on a couple sites) FilterField1/FilterMultiValue1 and various other permutations.
Perhaps unrelated but FilterOpX is being ignored as well. I saw several comments that this was a difficult-to-reproduce problem that occurred on some sites/lists and not on others...
Solución
So apparently the
useFiltersInViewXml=1
query parameter is a thing. Maybe just in SPO or maybe just in Modern Experience. I'm finding ZIP in terms of documentation from M$, but when I add that into my query:
.../AllItems.aspx?FilterName=MyTextColumn&FilterMultiValue=MyVal;YourVal&useFiltersInViewXml=1
then all of a sudden the world is my oyster...
Hope this helps someone else. If someone sees someplace where this is decently documented please comment below.
---EDIT---
My oyster ended up without a pearl. It works beautifully at first but some random number of seconds after that SPO does a reload via AJAX which ignores the filters I have specified.
TRY AGAIN:
This time I went into the unfiltered view, filtered by the columns I'm interested in, and reverse engineered the resulting URL. I end up with a query that looks like this:
.../AllItems.aspx?FilterFields1=MyTextColumn&FilterValues1=MyVal%3B%23YourVal&FilterTypes1=Text
Note that I have changed the URL as follows:
FilterFields1
instead ofFilterName
FilterValues1
instead ofFilterMultiValue
- separating my multi-values with
%3B%23
(which is;#
encoded) - added the
FilterTypes1=Text
query parameter for this "Single Line of Text" column type - no longer using
useFiltersInViewXml=1
Some "Gotchas" to be aware of:
- If your dynamic query sometimes allows multi-values and other times has only a single value you must change your URL (
FilterField1
andFilterValue1
without the s) FilterTypes1=Text
will change based on column type - manually filter and examine the resulting URL to figure out what you need- While
FilterName
/FilterMultiValue
supported (or was supposed to support)*
as a wildcard, this is not supported here with this syntax - I'm testing this only on Sharepoint Online as of Aug-2019 - YMMV elsewhere
Otros consejos
You need to use the Filter in below format:
.../AllItems.aspx?FilterFields1=MyTextColumn-FilterValues1=MyVal;#YourVal
Note ;# as a separator between two values.