13 Replies Latest reply on Jun 25, 2014 7:03 AM by philmodjunk

    new record in popover



      new record in popover


           How do I get a popover to populate a new record inquiry instead of a related record?

           Basically - I have layout that shows different clients in different roles.  I have a popover that you can use to add existing clients to the roles for the layout. I want to have a slide in my popover so that the user can slide over and add a new record if the record does not yet exist.

        • 1. Re: new record in popover

               Why would the popover create a related record? That won't happen unless you specifically design for that. And a "related record" might even be the best way to add a new record to your layout's table.

               Does the user decide that "the record does not yet exist" or will your database make that determination?

          • 2. Re: new record in popover

                 The popover shows a related record - as it should, I am sorry - I think i messed up my terms a bit there.  I do want it to be a related record... I just want it to be a new one.

                 The user decides if the record exists or not.  I am just confused as how when i drop the name fields for the contact in the popover how to get them to be blank and commit a new record rather that populate existing values.

            • 3. Re: new record in popover

                   The popover shows a related record

                   And what relationship do you have in place? What options have you specified for that relaitionship? Are you using a portal in the popover?

              • 4. Re: new record in popover

                     Yes I am using a portal in the pop over.  But not for the new contact field.

                     the popover is in the "listings" table.  listings is related to properties through a join table and properties is related to contacts through a join table.  The contact will eventually be populated into the join table for contacts and properties

                     I do have the relationships needed enabled to allow creation of records... Im not having a hard time with that end of it... its the easy part that is hurting here.  I just don't know how to populate new record fields in a portal.

                • 5. Re: new record in popover

                       Yes, but without knowing the relationships in place and the design of your layout, it's pretty difficult to answer your questions.

                       So you have these relationships:


                       and Your layout is based on the Listings table, but you want to be able to use the popover to add records in the Contacts table?


                            The contact will eventually be populated into the join table for contacts and properties

                       That statement goes to the heart of what makes this a less than straightforward process. This is unlikely to be just a simple case of creating a new record in Contacts. Then comes the need to link it to Properties before that contact becomes useful to the user. Since you are on a listings record that may be linked to multiple properties records, there is no specific record in Properties to which to link this new contact from what you have described thus far.

                       Please describe the design of your layout in much more detail and correct any errors I may have made in this post. From there, I think we can set up what you want.

                  • 6. Re: new record in popover

                         YEs - that is correct - except i apologize, I misspoke, there is no joint table between properties and listings.  

                    • 7. Re: new record in popover

                           Please describe the design of your layout in much more detail

                           I'm guessing that your portal might be to properties and that your popover button for adding a contact is included inside of the portal row. But I need to know if that is the case or not.

                      • 8. Re: new record in popover

                             In this scenario I have five portals.  all with different filters.  Each portal is based on the contacts/property join table and showing the fk from the join table and some phone numbers and email addresses from the contacts table.  The portals are filtered to the contact role field from the join table into the different portals.  buyers, sellers, listing realtors, selling realtors, and lender.


                             The pop over button is not in a portal... I was aiming to have one pop over button on the page, then when I input the information for the new contact I will populate the contact role field so it will show in its respective portal.

                        • 9. Re: new record in popover

                               I can think of two basic approaches here.

                               The simplest option to describe is that you define a set of global fields, one field for each contact field into which you want to enter data via the popover. You put the global fields into the popover.

                               To create a new contact record, you open the popover and enter data into these global fields. Then a script performed by an OnObjectExit trigger set on the popover, creates both the new record in Contacts and a new join table record linking it to the correct property record and thus the new contact should then appear in the appropriate portal. After creating the records, the same script then clears these global fields so that they will be empty the next time you open the popover and need to add a new contact.

                               The script would look like this:

                               Freeze Window
                               Set Variable [$PropertyID ; value: Listings::_fkPropertyAddressID ]
                               Go to Layout [ "Contacts" (Contacts) ]
                               New Record/Request
                               Set FIeld [Contacts::ContactName ; Globals::gContactName ]
                               #Put as many set field steps here as you have global fields placed in your Popover.
                               Set Variable [$ContactID ; value: Contacts::__pkContactID ]
                               Go to Layout ["jn_PropertyAddress_Contacts" ; (jn_PropertyAddress_Contacts) ]
                               New record/request
                               Set Field [jn_PropertyAddress_Contacts::_fkPropertyAddressID ; $PropertyID ]
                               Set Field [jn_PropertyAddress_Contacts::_fkContactID ; $ContactID ]
                               Set Field [ Globals::gContactName ; "" ]
                               #Put as many set field steps as you have globals in your popover here to clear them
                               Go To layout [Original layout]

                          • 10. Re: new record in popover

                                 amazing... thank you.


                            • 11. Re: new record in popover

                                   IM new to global fields obviously... but judging by the script it looks as though I am putting these global fields into a table that is specific for global fields?

                              • 12. Re: new record in popover

                                     I ended up adding a step to populate the TransactionRole in jn_PropertyAddress_Contacts.  

                                     My end result was 3 contacts were added, the last one had the name and information associated with it.  the join table had a new record placed in it with the transaction role field and nothing else... help me with where i went wrong?


                                     And if I click the popover button - but then realize I clicked the wrong button and exit out... it adds a blank record


                                • 13. Re: new record in popover

                                       The useful thing about fields with global storage is that they can be accessed from any layout, script or calculation in your file no matter what table they are defined in. So I tend to put all global fields in the same table (unless they are needed as a match field in a relationship) as way to keep better track of them.

                                       I suspect that the other contact records were not added by this script as I can see no way that this is possible. But you might have an issue with the script triggers. You can temporarily add a show custom dialog step to the beginning of this script and then you can test things and see if the dialog opens only once, or three times and when.

                                       With the join table record, it sounds like the variables, for some reason, are not getting any values. If you have FileMaker Advanced, enable the script debugger and step through this script using the data viewer to watch field and variable values to see what might be happening. If you don't have Advanced, you might put a Show Custom Dialog in and use it to display the values of both the variables just before the step where the new join table record is created and see if they have any value. you can also put in show custom dialog steps that display the value of the ID fields at the points where the variables are assigned those values.

                                       Please note that the Table occurrence names shown in Parenthesis in the go to layout steps, must exactly match the set field steps executed when that layout is the current layout. A layout based on a different occurrence of the same layout will cause an issue--you'd either need to change the set field step or change the layout specified to keep them matched up here.