Find Multiple records
How can I change this script to find multiple 'Assets'/ records with one search / Find:
Enter Find Mode[ ]
Set field [ Assets :: __KeypfieldName; Assets :: gBarcode ]
Set error capture [ ON ]
Perform Find [ ]
If [ Get (FoundCount) = 0 ]
Show custom dialog [ Invalid Search; "No records Found" ]
I have tried many things but can't seem to get it to function correctly, any advice would be appreciated, thanks
How will you capture multiple barcodes so you have such a list to use in your search?
If you can set up a script to capture a list of barcodes from your barcode scanner, a script can loop through such a list and create one find request for each barcode, then perform a single find to pull them all up?
Or you can start with an empty found set, use the script as written above, but change Perform Find to Extend Found Set.
I tried using the Extend Found Set  function, it does not seem to work. You can use the 'Find records' button on the top of your layout to 'Add a new request' to a search, allowing you to scan many bar codes into a single search. There would have to be a way of re-creating this function in a script??
Extend found set works. You click the find button, specify criteria and select Extend Found Set from the file menu. Click the find button again, specify criteria and then click extend found set....
This can be done in a script as well.
Enter Find Mode [ ]
Set field [ Assets :: __keypFieldName; Assets :: g__Barcode ]
Set Error capture [ ON ]
Extend Found Set [ ]
Show custom dialog [ Invalid search; "No records found" ]
If I run this script it still only seems to find one item at a time, the script is triggered on a text field (g__Barcode) using the 'OnObjectExit' trigger, what have I ballsed up?
What happens if you run this script 3 times with a different barcode in g__barcode each time?
The script won't run at all OnExit the barcode just sits there, maybe the script still needs the 'Perform Find' command?
The script should be fine. Perform Find is not needed. Extend Found set takes its place.
What trigger are you using and how is it set up?
How have you configured the barcode scanner to trip the trigger?
g__Barcode is a global Text field, so providing the cursor is in this field I can scan a barcode or manually enter the item's serial number. A script trigger is placed on the Text field, using OnObjectExit to trigger the 'Find' script. So once a barcode has been entered if I click on any are of the layout the script will fire - this is only tempoary while I refine the search script. This meathod was working correctly until a changed perform find to extend found set.
Note: I previously had a script that triggered a 'Go To Field' command using the barcode scanner to trigger a script in layout mode using the shift and ~ keys - sent prior to the bar code, as well as a button that would also trigger the search script vs an OnObjectExit trigger. However I have stripped all the back to simplify the process while I get the basic find script right.
As a test of your script, do this:
Do you get a found set of two records found, one for each barcode?
You may need to enable the "select contents on entry" feature for your global field before it will work with the script triggers.
Yes, If I follow the above prcedure it works correctly, two records are found.
On another note why does this forum only let me post text some of the time, its driving me nuts
That indicates that your script works correctly but how you manage your script triggers and scanner configuration have a problem.
Can you describe what you are experiencing when you try to post text and cannot? RightNow has recently put through changes in the interface without any advance warning and what appears to be sadly incomplete testing. W'eve spotted several issues to complain to them about and you may have encountered a new one.
One long standing bug that still exists is that if you access the forum on a daily basis but without logging in the first time each day, the system software can suddenly log you out without warning. If it logs you out while you are posting a message, the posted message disappears. As a precaution, I log out and back in every morning that I access the forum so that I don't waste my efforts typing up a message like this only to have it disappear.
What would you suggest to do about the script triggers, or could I add 'Show omited merords only' as part of the script?
Regarding this forum, the text box is not displayed, only the dark grey background and the image upload section, I need to submit a blank post, then proceed to edit it, or the text box will appear after I have made a post, also this problem is not consistant
I use two script triggers for this type of system. First trigger performs a script that simply puts the cursor into the global field so that the scanned data automatically appears in the correct field. Second trigger occurs when the data is fully scanned into the field and performs the above script to add the scanned record to your found set. You'll need to click a button or scan a special barcode affixed near the computer to initiate a new series of finds by performing a different script to set up the empty found set.
An alternative approach that seems simpler is to modify your process so that repeated finds are not needed. If you are scanning in loaned items when they are returned, your script can find and update the appropriate record to log the return of that item without needing to build up a found set of all returned items.
The last scanner I worked with was a magnetic strip scanner, but the process is the same. I set it up to preced each sacn with Shift-capslock-~. I chose that combination as a very unlikely combination to be pressed by the user directly on the keyboard. You may not be able to specify the shift or caps lock keys for your scanner so you may need to select a different combination of triggering characters.
On the layout where items are scanned, I then defined an OnLayoutKeystroke trigger to perform this script:
If [ Get ( TriggerKeystroke ) = "~" and Get ( TriggerModifierKeys ) = 3 // 3 means shift and caps lock keys are down] Go to Field [Yourtable::Yourglobalfield] Exit Script [false]End If
I then set up the scanner to append either tab, return or enter on the end of the scanned text. I use Field Behavior settings in the inspector to set up the global field so that the specified key will exit the field.
I then add an OnObjectExit trigger on the field to perform the script such as the script we've discussed here to process the data thus scanned. One advantage of this set up is that if a barcode won't scan due to damage to the label or your scanner breaks, you can manually type the barcode value into the global field and then press the specified key to exit the field in order to manually trip the same trigger to process the barcode.
Thanks for the tips, I managed to come up with this yesterday and I know a lot of people have been asking about multiple searches in the 'Lending Library' starter solution so if anyone else can get use from it please do..
It probably could be improved as I have only been using FM for a few weeks now but it seems to work ok;
Prefix character: ~
Suffix Character: #
NEW SEARCH BUTTON:
Go to Layout [ “Asset Form View” ( Assets ) ]
Show All Records
Show Omitted Only
If [ Get ( TriggerKeystroke ) = “~” ]
Clear [ Select; Assets :: g__Barcode ]
Go to field [ Assets :: g__Barcode ]
Exit script [ Result: False ]
Else If [ Get (TriggerKeystroke ) = “ ¶ “ or Get ( TriggerKeystroke ) = “ # “
Perform Script [ “Quick FIND SCRIPT” ]
Set Field [ Assets :: __KeypFieldName; Assets :: g__Barcode ]
If [ Get ( FoundCount ) = 0 ]
Show Custom Dialog [ “Invalid search”; “No Records Found” ]
Retrieving data ...