Build a Dynamic Filter from a form

%3CLINGO-SUB%20id%3D%22lingo-sub-87317%22%20slang%3D%22en-US%22%3EBuild%20a%20Dynamic%20Filter%20from%20a%20form%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87317%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHopefully%20someone%20can%20help%20me%20out%20here.%20I%20have%20a%20custom%20form%20on%20an%20SP%20Page%20that%20I%20need%20to%20use%20for%20filtering%20list%20items%20that%20have%20been%20returnd%20via%20a%20REST%20call%20and%20are%20being%20displayed%20in%20a%20table%20using%20Office%20Fabric%20UI.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EForm%20Fields%20are%3A%20Title%2C%20ID%2C%20Category%20(dropdown)%2C%20Status%20(dropdown)%2C%20ID%23%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I%20need%20to%20build%20a%20dynamic%20filter%20string%20to%20filter%20list%20items%2C%20so%20if%20there%20is%20a%20value%20in%20one%20of%20those%20fields%20then%20easy%20done%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eif%20(data.Title)%7B%3C%2FP%3E%3CP%3E%3CSPAN%3Efilter%20%3D%20%22%3C%2FSPAN%3E%3CSPAN%3E(substringof('%22%3C%2FSPAN%3E%20%3CSPAN%3E%2B%3C%2FSPAN%3E%20%3CSPAN%3Edata%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3ETitle%3C%2FSPAN%3E%20%3CSPAN%3E%2B%3C%2FSPAN%3E%20%3CSPAN%3E%22'%2CTitle))%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%7D%3C%2FP%3E%3CP%3Eetc%20etc%20etc%20for%20the%20other%26nbsp%3Bfields%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20what%20I%20need%20to%20happen%20is%20that%20if%20there%20is%20value%20in%20the%20Title%20AND%20in%20one%20of%20the%20other%20fields%20I%20need%20to%20CONCATENATE%20a%20further%20AND%20expression%20eg%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eif(data.Title%20%26amp%3B%26amp%3B%20data.Category)%20%7B%3C%2FP%3E%3CP%3Efilter%20%3D%20%22%3CSPAN%3E(substringof('%22%3C%2FSPAN%3E%20%3CSPAN%3E%2B%3C%2FSPAN%3E%20%3CSPAN%3Edata%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3ETitle%3C%2FSPAN%3E%20%3CSPAN%3E%2B%3C%2FSPAN%3E%20%3CSPAN%3E%22'%2CTitle))%20AND%26nbsp%3B%3C%2FSPAN%3E(ItemCategory%2FTitle%20eq%20'%22%2Bdata.Category%2B%22')%22%3C%2FP%3E%3CP%3E%7D%3C%2FP%3E%3CP%3Ethat%20is%20ok%20for%20that%20particular%20scenario%2C%20but%20what%20I%20am%20struggling%20with%20if%20is%20handling%20all%20the%20other%20%3CSTRONG%3Edifferent%3C%2FSTRONG%3E%20types%20of%20combinations%20of%20potential%20filters%20that%20a%20user%20may%20select.......%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Epleeease%20help.....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-87317%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPIs%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-87739%22%20slang%3D%22en-US%22%3ERe%3A%20Build%20a%20Dynamic%20Filter%20from%20a%20form%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87739%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F5720%22%20target%3D%22_blank%22%3E%40Vesa%20Juvonen%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Deleted
Not applicable

Hi all...

 

Hopefully someone can help me out here. I have a custom form on an SP Page that I need to use for filtering list items that have been returnd via a REST call and are being displayed in a table using Office Fabric UI.

 

Form Fields are: Title, ID, Category (dropdown), Status (dropdown), ID#

 

So I need to build a dynamic filter string to filter list items, so if there is a value in one of those fields then easy done:

 

if (data.Title){

filter = "(substringof('" + data.Title + "',Title))"

}

etc etc etc for the other fields

 

But what I need to happen is that if there is value in the Title AND in one of the other fields I need to CONCATENATE a further AND expression eg:

 

if(data.Title && data.Category) {

filter = "(substringof('" + data.Title + "',Title)) AND (ItemCategory/Title eq '"+data.Category+"')"

}

that is ok for that particular scenario, but what I am struggling with if is handling all the other different types of combinations of potential filters that a user may select.......

 

pleeease help.....

 

1 Reply