I'm wondering if you might be better off to use a filtered portal for this instead of performing a find. What are you trying to accomplish with this combination of script and search field?
I have a demo file where you can type in text and the portal filter filters the list of portal records to list only the records were the text in a description field starts with the same text that you entered into the search field:
The portal at bottom right does the same type of search you describe here.
Thanks for your response, I have a product list I want to narrow down then the user can add items from this list to an order (need this to be "starts with" search).
I have managed to set this up through a filtered portal using the method you have suggested but the problem is that I am using the file on FMGO and due to the poor refresh rate on the iPad (when I have to refresh the window everytime I enter a character) I was trying to do this in list view instead to see if I could get a better response time.
Hmmm, the problem is that "starts with" requirement. That's easily handled in the filter expression (which is why I recommended it.)
Here's an "old school" solution to this problem.
Define a different calculation field that strips all spaces and other word separators out of your description field:
Substitute ( DescriptionField ; " " ; "" )
Perform your find on this field that has turned your text into a single merged word instead of the original description field.
If you need to eliminate addititional characters, you can include pairs of find/replace strings inside [brackets]. Look up Subsitute in FileMaker help to see the correct syntax for this.
'starts with' isn't difficult in a regular find. Manually you would type ==bla*
I am not familiar with GO so you'll have to experiment but this script works well in regular files:
Use this script attached to SearchText (global text) script trigger OnObjectModify:
Set Error Capture [ On ]
Set Variable [ $field ; Get ( ActiveFieldName ) ]
Exit Loop If [ Get ( ActiveFieldName ) ≠ $field or IsEmpty ( Products::SearchText ) ]
Set Variable [ $find ; "==" & Products::SearchText & "*" ] ... see note below
Perform Find [ Restore ]
Go To Field [ Products::SearchText ]
Note: here you create the stored find by selecting your Products::Name field and then in criteria just type $find.