Ralph Schwegler Posted February 8, 2010 Posted February 8, 2010 (edited) Dear geeks I am currently trying to solve a really basic problem, and I reach the point which makes me see that FileMaker 10 has many more secrets to me than I thought. I have a table with names and zip code (among others) and I try to make the names appear in a portal if they have either the beginning numbers of the zip i'm entering or the beginning of the name I am entering (if I enter "R" I could see Ralph and Robert, if I enter "Ro" Ralph disapears from the portal). I'm quite confident that this should be possible, but I had no chance to date... Can anyone help me on that? Cheers EDIT: I managed to do a part solution with script triggering, modifying the DB "athletes" I found on the forum. trigger.fp7.zip Edited February 8, 2010 by Guest ADDED THE FIRST ALPHA OF MY TEST
Cortical Posted February 8, 2010 Posted February 8, 2010 (edited) Ralph, this can be done but you are missing some building blocks. Other may suggest variations, or alternates, but this works for me. In this example name and urn (both text fields) What you are trying to do is an either/or or a partial both (? either/and) search. As always there may be other ways but this works for me: the two search globals require a upper limit calc for each e.g. g_search_name c_search_name = If( IsEmpty( g_search_name ) ; "zzz" ; Trim( g_search_name) & "zzz" ) Part of making this work, is allowing for one of the search globals to be empty. If in the data, the second parameter (urn) can also be be empty, then this needs an additional calc in the data to return a filler value, or else the search result will be a false set. The name field is assumed to be non null. example fields to search: last_name urn_code if urn can be empty, then this requires a calculated result; which must be indexable (right side of rel); make it an auto enter calc for efficiency aec_seacrh_urn = If( IsEmpty( urn_code ); 1 ; urn_code) Test the 1 result to see how it affects the accuracy of the search result g_search g_search_urn c_search_name_a = If(IsEmpty( g_search) ; "a" ; g_search) c_search_name_b = If( IsEmpty( g_search ) ; "zzz" ; Trim( g_search) & "zzz" ) c_search_urn_a = If(IsEmpty( g_search_urn) ; "0" ; g_search_urn) c_search_urn_b = If( IsEmpty( g_search_urn ) ; "zzz" ; Trim( g_search_urn) & "zzz" ) Note that the rel target aec_search_urn is a text field; if it was a number field, then the "zzz" in c_search_urn_b would probably need to be a large number (10,000,000) The multi-parameter search rel c_search_urn_a <= aec_search_urn c_search_urn_b >= aec_search_urn c_search_name_a <= aec_last_name c_search_name_b >= aec_last_name This will give a functional search; but require clicking outside the field to refresh the search result SCRIPT TRIGGERS triggers can be used to implement a true type ahead/back 'clairvoyant' filtered search, the extra element here is to get the insertion point to stay in the same field and the same position, plus incorporating an exit out of the search field on tab, return or enter. Define the Filed Behaviour of each global to go next object for tab/rtn/enter and also remove the tab order from the layout there are other variations on this to suit particular requirements, but this is a start position. attach OnObjectKeystroke to each search global field define a script parameter for each, as this is used to target the correct field to return to I use the same scripts for multiple purposes so the SP is 2 part g_search ST: OnObjectKeystroke SP: "search|name|" g_search_urn ST: OnObjectKeystroke SP: "search|urn|" define each OnObjectKeystroke script trigger to run script: st_commit_triggerkeystroke this is the script that exits the field on tab/return/enter script excerpt: st_commit_triggerkeystroke #CONTROL VARIABLES Set Variable [ $_ex; Value:getSP_n ( 1 ) ] Set Variable [ $_q; Value:getSP_n ( 2 ) ] # # # triggerkeystroke: tab = 9 # triggerkeystroke: return = 13 # triggerkeystroke: enter = 10 # # If [ Case( // tab prevent tab string insertion in URN field Code( Get ( TriggerKeystroke ) ) = 9 and getSP_n ( 1 ) = "URN" ; 1; Code( Get ( TriggerKeystroke ) ) = 10 ; 1; Code( Get ( TriggerKeystroke ) ) = 13 ; 1; )] Commit Records/Requests [ Skip data entry validation; No dialog ] Else // other search origins... End If attach OnObjectModify trigger to each layout search global. The OnObjectKeystroke is the first to execute, and if the keystroke was not tab, return, or enter, will have no effect, and the second ST will execute running the script st_refresh_on_modify; each global will pass an identifying script parameter to the script; the SP is used to target the cursor return. This script forces the cursor to appear to stay in the same point of the same field DEFAULTS: st_refresh_on_modify #26/1/10 #this triggered by OnObjectModify gives true progressive filtering as you type, letter by letter, type forward or delete, maintains cursor insertion point #can be used on multiple layouts and fields #SP: Layout|Field # #CONTROL VARIABLES Set Variable [ $_ex; Value:getSP_n ( 1 ) ] Set Variable [ $_q; Value:getSP_n ( 2 ) ] Set Variable [ $_field; Value:Get ( ActiveFieldName ) ] # # Set Variable [ $_start; Value:Get ( ActiveSelectionStart ) ] Set Variable [ $_size; Value:Get ( ActiveSelectionSize ) ] Commit Records/Requests [ Skip data entry validation; No dialog ] Refresh Window [ Flush cached join results ] # # #MANDATORY GoToField keeps the cursor in the same position If [ $_ex = "admin" ] // do stuff Else If [ Get ( LayoutName ) = "search_all" ] I If [ $_field = "g_search" ] Go to Field [ aUser_review::g_search ] Set Selection [ aUser_review::g_search; Start Position: $_start; End Position: $_size ] Else If [ $_field = "g_search_urn" ] Go to Field [ aUser_review::g_search_urn ] Set Selection [ aUser_review::g_search_urn; Start Position: $_start; End Position: $_size ] End If End If That should cover it. Edited February 8, 2010 by Guest
Ralph Schwegler Posted February 9, 2010 Author Posted February 9, 2010 Chris, Thank you so much for your answer, I will try to understand and implement that in the posted example. I will keep you posted with an updated file. Cheers
Lee Smith Posted February 9, 2010 Posted February 9, 2010 Hi Ralph, Here are some files that may help. The description by Cortical sounds like Nightwing's Instant Search which you an find here; Link Also, this demo by comment might be helpful to you; Link and this file by Excelisys called As–You–Type Search Filtering found here; Link HTH Lee
Cortical Posted February 10, 2010 Posted February 10, 2010 Different approach to Nightwing's which is a find based list. Different approach to SeacrhMultiple which is again a find/list, and requires a user click to execute. Excelisys is also a find with a list result My approach is a filtered rel and portal result, two field either/or or partial and/and with true clairvoyance.
Lee Smith Posted February 11, 2010 Posted February 11, 2010 My response was directed Ralph Schwegler.
Recommended Posts
This topic is 5398 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now