6 Replies Latest reply on Aug 6, 2009 9:50 AM by KBGF75

    newbie scripting problem

    KBGF75

      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

        • 1. Re: newbie scripting problem
          comment_1
            

          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.

          • 2. Re: newbie scripting problem
            KBGF75
              

            Thanks. The Go to Related Record step now does what I want, though I added two steps: Sort Records and Go to Record/Request/Page.

             

            Although the script works well on the desktop, I'd like it also to work via a browser. Although FMP Help says all steps are web-compatible, I don't get the desired result when I try it in a browser window. The screen refreshes, and a progress bar appears to show activity to quick completion, but the layout view is unchanged.

             

            What might I be overlooking?

                  -Al

             

            • 3. Re: newbie scripting problem
              TSGal

              KBGF75:

               

              Thank you for your posts.

               

              I don't know what you are overlooking.  This is what I have done...

               

              1. I created a two test tables (MASTER and LOOKUP), with a common key field "ID".

               

              2. I added a few records to LOOKUP with two different ID's (1 and 2)

               

              3. In my MASTER layout, I created a portal into LOOKUP that included some fields.

               

              4. In the MASTER layout, I enter ID: 1     and three records display in the portal.

               

              5. I created a script "Go To Related Record", with the script step:

               

              Go to Related Record [ Show only related records ; From table: "LOOKUP" ; Using layout: "LOOKUP" ( LOOKUP ) ]

               

              6. I create a rectangle button that executes the script "Go To Related Record".

               

              7. In Browse Mode, I click the button, and the script takes me to the three related records in the layout "LOOKUP".

               

              8. I turn on Instant Web Publishing and set access for the file to all users.

               

              9. I go to another machine, launch a browser, enter the IP Address of the host machine, and select the file from the Instant Web Publishing page.

               

              10. I go to the MASTER layout, display the record with ID: 1, click the button, and I switch to the LOOKUP layout where the three related records are displayed.

               

              Please let me know what I'm doing differently than you, and I'll try to duplicate the problem here.

               

              TSGal

              FileMaker, Inc. 

              • 4. Re: newbie scripting problem
                KBGF75
                  

                TSGal:

                 A word of background: I maintain and host this non-profit database on my home PC. A volunteer colleague works with me, accessing the file remotely via Instant Web Publishing.  Periodically I do the same from another machine of my own, usually to test, troubleshoot, or verify normal IWP operation.  It appears that your procedure and mine are much the same. 

                 

                I suspect the script steps are not at fault, since the script delivers the desired results on the host PC.  The three steps are:      

                  1. Go to Related Record [Show only related records; From table: “Donations”; Using layout: “Donation Data Entry” (Donations)]   

                  2. Sort Records [Restore; No dialog]   

                  3. Go to Record/Request/Page [Last] 

                 

                My Contacts layout also includes a portal that displays data from the related Donation records. Related record data do show in the portal when viewing via IWP. 

                 

                Re your steps 8-9, my IWP is always on. Access is limited to specific users and privileges.  

                 

                As mentioned earlier, when I push the script button on the IWP layout, the screen refreshes and a progress bar appears briefly, but I still end up looking at the Contact record. I wondered if, somehow, the related Donation records had been found and sorted anyway, but not displayed. Going manually to the Donations layout, after running the script, shows that has not happened. 

                 

                                -Al

                • 5. Re: newbie scripting problem
                  TSGal

                  KBGF75:

                   

                  Thanks for the update.

                   

                  The progress bar is displaying probably because of the sort.

                   

                  My first thought is that the access privileges do not allow access to the "Donation Data Entry" layout.  One way to check this is to disable the last two steps and just see if you can switch to that layout.  If this works, then add the sorting step next, and try again.  Finally, add the last step.

                   

                  Please continue to keep me updated.

                   

                  TSGal

                  FileMaker, Inc.

                  • 6. Re: newbie scripting problem
                    KBGF75
                      

                    TSGal said: My first thought is that the access privileges do not allow access to the "Donation Data Entry" layout.

                     

                    You were right. I was using an IWP login that (as a test) had been denied access to the Donation Data Entry layout. Mea culpa, apologies, and thanks.

                     

                    My next challenge is to create a script that can be executed (from a Contacts record) to open a new, related Donations record. Easy to do with a portal entry, but I'd prefer to use a button. The path is not clear, so I may have to make it the subject of a new post.

                               -Al