10 Replies Latest reply on Feb 6, 2013 6:45 PM by BruceHerbach

    Creating a new related record

    user19154

      Hi there,

       

      We're having some issues with fine tuning our system. Maybe someone can halp us.

       

      We've made a layout linked ('homepage') to a the table called 'klant'. And there is a layout called 'invoer melding', this layout is also linked with the 'klant'-table. This layout (invoer melding) contains a lot of related inputfields. Easy so far!

       

      There is a button on the homepage that sends you the layout 'invoer melding' now i want to create a new related record if i enter that layout en not want it to show the last record. (because the most of the inputfields are related to a 'meldingen'-table)

       

      Greets.

        • 1. Re: Creating a new related record
          gdurniak

          I will guess this is a Form Layout, with no Portal ?

           

          is "last record" the one you just created ?

           

          greg

           

          > now i want to create a new related record if i enter that layout en not want it to show the last record

          • 2. Re: Creating a new related record
            user19154

            Yes, it's a Form Layout without a portal. With last record i mean the last record a user submitted. But i don't want my users to see the last entries from other users. When the go to the layout by button, the fields must be all empty and ready for a new related record. So the scriptstep 'create new record' wont work in this situation because the fields are related-records.

             

            William

            • 3. Re: Creating a new related record
              gdurniak

              if each Relation is also based on the current user name,  then each user would only see their own entries

               

              greg

               

              > But i don't want my users to see the last entries from other users

              • 4. Re: Creating a new related record
                user19154

                True, but i dont want them to see any record. I want them to fill in a brand new entry in the related record.

                 

                William

                • 5. Re: Creating a new related record
                  gdurniak

                  I'm not sure what you need

                   

                  Perhaps go to a "user" table with one blank record for each user,  then set a global key,  to open the Related Fields ?

                   

                  greg

                   

                  > but i dont want them to see any record. I want them to fill in a brand new entry in the related record

                  • 6. Re: Creating a new related record
                    BruceHerbach

                    Rob,

                     

                    It sounds like you should script the layout change and new record operation.  I'm assuming that you have a relationship  klant::ID  = meldingen::kfID possibly set so that the meldinen side has the "allow creation ofreconds in the  table via this relationship" checked.  See the attached images to see what I mean.

                     

                    When your script goes 'invoer melding' layout have it either do a find for a record you want to display or have it "show all records" then "show omitted only".  This will leave them on empty record with no data in any fields.

                     

                    At this point you can have a button with a script that creates a new record or record set.  If I understood this correctly the layout is on the klant table and displays data from both klant and the related meldingen table record.  If this is the case you can create a new record in the klant table.  When the user goes into a field from the meldingen table on the layout and enters information,  FileMaker will create the new record and set the value for the foreignkey in the meldingen table.

                     

                    The other scripted option is to create the klant table then using set field set the value of the foreign key into meldingen record.  This will also create the record for you.  If you don't have the create record throught the relationship set.  Then have the script put the Klant::ID in a variable,  open a new hidden window,  change layouts to one based on meldingen.  create a new record and set field for the foreign key with the value from the variable.

                     

                    HTH
                    Bruce

                    1 of 1 people found this helpful
                    • 7. Re: Creating a new related record
                      user19154

                      Hi Bruce,

                       

                      Yes, the 'Klant' and 'Meldingen' tables are linked by unique ID's. The "allow creation ofreconds in the  table via this relationship" is cheked indeed!

                       

                      When your script goes 'invoer melding' layout have it either do a find for a record you want to display or have it "show all records" then "show omitted only".  This will leave them on empty record with no data in any fields.

                       

                      When i select "Show all records" it will show all records of the linked table (klant) and not the related table (meldingen). And when i make a button that creates a new record or record set, it will do this (again) only for the linked record, not the related record.

                       

                      Maybe it will help to explain the situation of our system;

                       

                      We're creating a system for a company, they have a layout called 'klantkaart' this is a card with information about they're clients. From there the people on the ground (co-workers) can fill in reports by clicking the 'Invoer Melding' button, this button links to the 'invoer melding'-layout and this layout is also linked to the 'klant'-table. But in this 'invoer melding'-layout there a lot of related-inputfields, and they have to be clear(new-record in the related table) once the co-worker enters this layout.

                       

                      William
                      Creator Networks

                      • 8. Re: Creating a new related record
                        BruceHerbach

                        William,

                         

                        It sounds like you have to base the new record layout on the Meldingen table and set the foreign key for the parent record in the klant table.  So when the click the 'Invorer Melding' button the script should do the the following:

                         

                        Freeze Window  // This will freeze the display so that the user doesn't see data on the screen until the script ends.

                        Set variable [ $kfID; klant::ID ]

                        Go to layout [klankaart]  //This should be a data entry layout based on the Meldingen table

                        Set field [ kfID; $kfID ]

                        Commit Record   // this should refresh the screen and show the user the new record with empty fields ready for data entry.

                         

                        This should bring the user to the new/blank record with out displaying data from previous records related to the same Klant table record.

                         

                        Bruce

                        • 9. Re: Creating a new related record
                          user19154

                          Bruce,

                           

                          Thanks a lot! This solved my problem

                           

                          Greets, William

                          • 10. Re: Creating a new related record
                            BruceHerbach

                            Very happy to hear it.

                             

                            Bruce