5 Replies Latest reply on Aug 19, 2014 8:47 AM by LeonGatewood

    Trouble with Script Using Portals and Copy and Paste function

    LeonGatewood

      Title

      Trouble with Script Using Portals and Copy and Paste function

      Post

           I need to be able to create a found set, and then once I've created it, run the following script, which adds data into several fields in a portal.

           The one sticking point is that I'm having trouble copying a date from a field in our main data file into a date field in the portal.  I'm using the copy and paste function (maybe I should use a different method?)  The only way I've gotten it to work is to put the date into the first row of the portal but I need it to go into the last row of the portal.  Any help is greatly appreciated, Thnx.

           I'm using FM Pro 8.

        • 1. Re: Trouble with Script Using Portals and Copy and Paste function
          philmodjunk

               There is no "following script" in your post. See the info at the end of this post for a list of methods that can be used to post a script to this forum.

               Copy and Paste should work but are not the ideal method as Copy overwrites any data in the clipboard that a user may have previously copied. This confuses and irritates people and is easily avoided by using other methods to move data from one place to another in FileMaker.

               Instead of Copy, use Set Variable. Instead of Paste, use Set Field and refer to your variable in the calculated results portion of set field.

               There is a script step, Go to Portal Row [Last]

               That can put the focus into the last row of the portal so that a set field step will modify a field in the last portal row instead of the first.

               But this can be complicated by the fact that the last portal row may or may not be a special "add row" for adding new related records. This will be the case if "allow creation of records via this relationship" is enabled for the portal table in the relationship on which this portal is based. If an add row exists in the portal, this combination of go to portal row [last] and set field will create a new portal record. If such a row does not exist, the same steps will modify data in the last existing record in the portal.

               To post a script to the forum:

                 
          1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post a New Answer.
          2.      
          3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
          4.      
          5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
          6.      
          7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
          • 2. Re: Trouble with Script Using Portals and Copy and Paste function
            LeonGatewood

                 Thanks Phil, that worked perfectly!  Here's the working script:

                  

            • 3. Re: Trouble with Script Using Portals and Copy and Paste function
              LeonGatewood

                   Oops, here's the script:

              • 4. Re: Trouble with Script Using Portals and Copy and Paste function
                philmodjunk

                     Nope. No script. Are you perhaps trying to upload a PDF file to the forum. That won't work. See the file types listed with the Upload an Image controls.

                     But if "that worked perfectly", why do you need to upload the script?wink

                • 5. Re: Trouble with Script Using Portals and Copy and Paste function
                  LeonGatewood

                       You are correct on all counts!