Thursday, November 26, 2009

FileMaker Multiple word(part) portal filter


This technique might be known by some, but I'm pretty sure that it isn't know by many.
What we want to create is a multiple word (or wordpart) portal filter.


Many single word FileMaker portal filter demonstrations can be found on the net, but currently I needed one that can filter by multiple words.

Here's how I did it.

First we need a searchfield on the layout. I called this SearchField_Display.
Then we need a custom function that can create the variations of our fields.

I chose AllTextCombination by Peter Gort (it can be seen here, at Brian Dunning's custom function library).

With this function we create an AllVariation field based on our fields:

AllTextCombinations ( FirstName ) &"¶" & AllTextCombinations ( LastName ) & "¶" & AllTextC

ombinations ( City ) & "¶_ALL_"


The "¶_ALL_" at the end will be important later. That's used to show all the records is the searchfield is empty.


If we have this, we need three additional fields, which will help us to create a 3 word search ability. (note: if you want four words, then you'll need four, but I think 3 must be enough).


I call them SearchField1, SearchField2 and SearchField3, and they are unstored text calculations:


SearchField1:

Let ( s = Substitute ( SearchField_Display ; "-" ; " " ) ;If ( IsEmpty(s) or IsEmpty(MiddleWords(s;1;1)) ;"_ALL_";MiddleWords(s;1;1) ))


SearchField2:

Let ( s = Substitute ( SearchField_Display ; "-" ; " " ) ;If ( IsEmpty(s) or IsEmpty(MiddleWords(s;2;1)) ;"_ALL_";MiddleWords(s;2;1) ))


SearchField3:

Let ( s = Substitute ( SearchField_Display ; "-" ; " " ) ;If ( IsEmpty(s) or IsEmpty(MiddleWords(s;3;1)) ;"_ALL_";MiddleWords(s;3;1) ))


As you may notice the only difference is the word which we get from them.

I also used a Substitute ("-" to a Space char) as my data contained many "-" chars, and I wanted them as different words).


By these we can create a relation to AllVariation:



As you can see we'll have 3 criterias. (If you want 4 word you'll need 4).


After this, if we use the portal filter we'll be able to search for things like: "we la c", or "an li v" or "Bil bar abi" so basically any part of our fields.

I attached a demo file which you can download from here . (right click- save as).


Note1:The demo uses Brian Dunning's sample data database which I downloaded from here.
Note2: I used many fields in the AllVariation field which makes the index huge. You shouldn't need to do that!

Please also visit our site, http://crm.fm which has our main FileMaker product, and support us by buying it. Thanks!

The material on this document is offered as is. There is no representation or warranty, expressed or implied, nor does any other contributor to this post. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.






No comments:

Post a Comment