Here is a demo file that does exactly what you describe if you check out the portals at the bottom of the layout:
Note that these portals use scripts that create related records in tables that are linked with serial number ID fields--not names.
Hey Phil, thanks for the link it works great! The only problem i still ran into was that when i tried searching something it would only find a matching record based on the first word.
For anyone interested in this example but wants multi-word search i will copy the custom function i used:
FindWordPartsInText (Needles; Haystack; Start) =
needle=LeftWords (needles ;1);
WordCount ( needles) < 2 ; 1 ;
FindWordPartsInText (RightWords ( needles;WordCount (needles ) -1 ); haystack ; 1 )
); FindWordPartsInText (needles;haystack;start +1)
This custom function allows users to type in "bubblegum flavor" even though the record is saved as "flavor, bubblegum" and i will still find the matching record
You filter the search portal with this calculation:
FindWordPartsInText ( *GlobalSearchField* ; *SearchPortalField* ; 1 )
Actually, the filtered portal on the bottom right in the demo file uses PatternCount to match the search text against all text in the specified field. That can be any number of words in the same field.
Hmm, it is the filtered portal on the left that uses patterncount, i used the portal on the right.
Ok, my mistake, but the pattern count version should work for you here unless you need to compare against only the start of each word in the field instead of patterncount's "contains" logic.
I initially only looked at the portal on the right, but playing around with the patterncount portal your correct in that it would also do what i needed.
Hey Phil, After further testing i scrapped the bulky CF and implemented the patterncount filter, it will easily do everything i need! Thanks again.
I have a new question. I've added a couple new script steps that i believe will streamline user input, they esentially allow the user the jump back to the search field after they have inputted data into the "amount" field.
The two steps i have added:
Go to Field (Compound Formula::IngredientSearch)
What i can't figure out is how to continue the script without having the move the cursor to the resume script button at the top. When i click enter/return it just creates a second line within the "amount" field, and in the inspector if i enable enter and return to move to next object it moves me to the next portal row. I know i'm being picky i was just hoping to move throughout the layout without having to use a mouse. Any suggestions?
You might play with the onObjectKeystroke trigger on the field in question so that the triggered script tests for the Enter key and then moves the cusor to the correct spot when the key is pressed.
I played around with all of the script triggers, and the closest i came was onObjectValidate. I press tab when in the amount field, the cursor briefly goes into the search field and then reverts back to the next portal row...
I'm thinking the validate,save,exit object script triggers have trouble with this because the portal is the actual object and not the amount field within the portal?
Try ending your onObjectKeystroke triggered script with Exit Script [False]
This cancels out the return, tab or enter key that your script detected and used to move the cursor to the search field.
If [ code ( Get (TriggerKeyStroke ) ) = 9 // tab key]
Go To field [Yourtable::yoursearchfield]
Exit Script [False]
wow, very nice! That works perfectly, thanks again!