Re: AS/FMP: a list of fewer than two records
Re: AS/FMP: a list of fewer than two records
- Subject: Re: AS/FMP: a list of fewer than two records
- From: Chap Harrison <email@hidden>
- Date: Sat, 28 Feb 2004 00:06:20 -0600
Just for the archives, if anyone is Googling for "Applescript Filemaker
Empty Found Set Error". Corrections welcome!
Problem: Filemaker's implementation of (ID of every record whose
<criteria>) returns (a) a list for two or more qualifying records, (b)
a scalar for exactly one record, and (c) an "object not found" error
for zero records.
Here is a way to get Filemaker to return 0 or more record IDs in a
list, over which you may write a nice straightforward 'repeat':
1. tell application "FileMaker Pro"
2. tell database gLineItemsDB
3. if (exists (record 1 whose cell "Price" is "*")) then
4. set myList to ID of (every record whose cell "Price" is "*") as
list
5. else
6. set myList to {}
7. end if
8. repeat with myID in myList -- now iterate over a list of ZERO OR
MORE ids, as God intended.
9. set myOrderNumber to cell "webOrderNumber" of record ID myID
10. set myInvCode to cell "InventoryCode" of record ID myID
11. my setInvCodeError(myOrderNumber, myInvCode)
12. end repeat
13. end tell
14. end tell
Statement 3: only use a simple criterion. anything more complex gets
FMP confused. don't expect miracles.
Statement 4: 'as list' is important for the case where exactly one
record is found.
Statement 8: Loop zero times if zero items in list; loop one time if
one item in list; twice if two; etc. Patent pending.
Thanks to Michael Grant for suggesting the solution.
Chap
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.