7 Replies Latest reply on Nov 10, 2014 6:40 PM by PeterDurant

    Replace Field Contents



      Replace Field Contents


      Hi Everyone,

      I need some help populating a linked table using the "Replace Field Contents" command.  Here is what I have:

      I have a contact management database with a number of people in it that I want to send my newsletter to and record it in a separate table called "Subscriptions".  So I do a search of the people (say Seniors over 65) and perform find.  I can then go into the Subscription portal for each person and tag them as receiving the newsletter but if I have thousands of people that is very time consuming.

      I have tried the "Replace Field Contents" but it doesn't populate the subscription table for each person.  Any suggestions for a way to do this?



        • 1. Re: Replace Field Contents

          Can you provide just a little more detail about how you "Tag" them? Is this setting a value in an existing record in the portal or are you creating a new related record in this portal?

          • 2. Re: Replace Field Contents

            Hi Phil,

            On my contact management layout I have a portal to the Subscriptions table.  The portal contains two fields: subscription and a date stamp.  The subscription field is a drop down with the various subscriptions: Newsletter, Nov Solicitation Letter, etc...

            So when I do a Find for a group of contacts, I then go to the subscription portal and choose "Newsletter" then go to the next record and choose "Newsletter" and continue until done.  The problems is where there are 100's of people to do, it is tedious.  

            I am trying to automate that function.



            • 3. Re: Replace Field Contents

              I'm sorry but that did not answer my question. Does this action update an existing record in the portal or are you creating a new record in the portal? There's a way to do the first via replace field contents on a different layout, but not the second--a different method than replace field contents would be needed.

              The key visible difference is whether you are finding an existing row of data in the portal and changing a value in the field or entering data in to a new blank row in the portal.

              • 4. Re: Replace Field Contents

                Sorry Phil, I am creating a new record in the portal.

                • 5. Re: Replace Field Contents

                  Then you will need to use a different method than replace field contents.

                  After performing the find--which can be a scripted or manual find, to produce a found set of parent records, a script can loop through the records and create one new related record in the portal's table for each record in your found set.

                  The exact script can vary a bit with the version of FileMaker that you are using. THis script should be one that you can adapt to nearly any recent version of FileMaker by using your field names in place of mine.

                  Say that you have these tables and relationships:


                  People::__pkPeopleID = Subscriptions::_fkPeopleID

                  #after performing your find....
                  Go to record/request/page [first]
                      Set Variable [$PeoplieID ; People::__pkPeopleID ]
                      Go to layout ["Subscriptions" ( Subscriptions) ]
                      New Record/Request
                      Set Field [Subscriptions::_fkPeopleID ; $PeopleID ]
                      #Put any other set field steps that you need to assign values to this new record here
                      Go to layout [original layout]
                      Go to Record/request/page [next ; exit after last]
                  End Loop

                  With FileMaker 13, you also have the option to use the new "list of" summary field to get a list of the __pkPeopleID values of your entire found set and copy it into a variable. Then the loop shown above can be modified to loop through this list of values without changing back and forth between layouts for each new record created.

                  • 6. Re: Replace Field Contents

                    HI Phil,

                    That worked great.  One other question: I would like to have a pop up appear at the start of the script with a warning message that gives the user the opportunity to continue or abort the script.  I used the Show Custom Dialog command but how do I get the script to abort if the user clicks cancel?

                    • 7. Re: Replace Field Contents

                      Never mind Phil, I got the script to abort with the Get function.