Title
newbie scripting problem
Post
My FMP9 file includes a table of Contacts and a table of Donations. Donation records are related to the donor‘s Contact record by contactID fields (a Donation record’s contactID_fk will always match the Contact record’s contactID_pk).
My first scripting attempt (ever) has a problem. The concept is to initiate the script while in the Contact record of a particular donor, and the script then finds and sorts related Donation records as follows:
Step 1: copy the contents of the contactID_pk field
Step 2: go to a donations layout (that contains a contactID_fk field)
Step 3: enter the find mode
Step 4: go to the contactID_fk field (while still in Find mode)
Step 5: paste into that field what was copied in Step 1
Step 6: perform the Find (without dialog)
Step 7: sort the found records (by date of donation)
Here are the script steps:
1. Copy [Select; Contacts::contactID_pk] (select entire contents)
2. Go to Layout [“Donation Data Entry”(Donations)]
3. Enter Find Mode []
4. Go to Field [Donations::ContactID_fk]
5. Paste [Select; Donations::ContactID_fk] (select entire contents)
6. Perform Find/Replace [No dialog]
7. Sort Records [Restore]
8. Allow User Abort [On]
When the script runs, it ends in the Find mode for the donations layout. No value has been entered in any field. If I wished, I could continue the find and sort steps manually. Steps 4 and 5 look suspect. Any advice will be welcome.
-Al
You are using Perform Find/Replace[] instead of Perform Find[].
Note:
1. You should be using script variables (or script parameter) instead of Copy[], and Set Field[] instead of Paste[]. Leave the clipboard to the users.
2. The Go to Related Record [] step can do all of your steps 1 - 6 at once.
3. Your step 8 is not necessary - certainly not at the end of a script.