7 Replies Latest reply on Feb 9, 2017 4:02 PM by BeatriceBeaubien

    Related Record via a Popover

    llweisscptc

      I am new to FM and I am struggling with getting this to work. I have read a bunch of the suggestions in other discussions, but I am doing something wrong.

       

      I am connecting to a MS SQL database so I can not provide a database file, but I have attached screen shots. I have a table Panelist (pk is pn_ID) related table PanelistITA (pk is pita_ID and fk pn_ID) that contains ITA records for the panelist.

       

      I am trying to use a popover entry of new ITA records.

       

      I have two popovers just to show the two different ways of trying to do this but I am failing at both I think in my scripts or where the script is attached.

       

      Any help would be appreciated.

       

       

      relationships_PanelistITA.png

       

      layout_panelistITAportal.png

       

      popover_addITARecord_PanelistITAtable.png

       

      popover_add_button_script_addITARecord_PanelistITAtable.png

       

      popover_addITARecord_globalstable.png

       

      popover_add_button_script_addITARecord_globalstable.png

        • 1. Re: Related Record via a Popover
          philmodjunk

          How does this fail for you?

           

          The scripts look OK though it's not a method that I use much anymore. (I prefer MagicKey as it avoids the need to change layouts)

           

          But the relationships look problematic.

           

          If these were FileMaker tables rather than shadow tables to an external source, the "Tee" connectors shown would indicate a global, unstored or at least unindexed match field. You can get away with one such in a relationship if you only use it to reference data from the context of the field with the unindexed field, but you can't have both unindexed and so the relationship doesn't look right to me.

          • 2. Re: Related Record via a Popover
            llweisscptc

            The New ITA popover on the left opens with the last ITA record prepopulated. Changing any of the data edits that record ( I do not want to allow changes either after the initial entry.)

             

            The New ITA Global popover on the right opens with the last information I attempt to add, but the record is never added nor are the globals cleared.

             

            I am not sure what you mean by Tee connectors.

             

            (Ignore the fmPanelistITA fm table and vw_Panelists_for_sunscreen_ITA shadow table on the relationship graph as that was me trying the same ideas but with an FM PanelistITA table and a SQL view from the Panelists table.)

             

            As far as indexes, in the SQL server the tables are indexed properly. Am I understanding that FM has no idea that those indexes exist? Is there a way that this is done with shadow tables in FM?

             

            (Sorry, I programmed for years in Access and VB/ADO.net before the major changes to the language and constructs. I guess I am just having a hard time grasping something that was quite simple to do in those programs.

            I have always programmed stored procedures to add records in the SQL Server, but FM doesn't play nice with stored procedures.)

             

            I can try magic key as I have read references to it, but based on my previous experience I didn't understand why the workaround was necessary as these type of one to many relationships aren't an issue in those programming languages.

             

            I like what I see in FM and figuring this out is something I have to do.

            • 3. Re: Related Record via a Popover
              philmodjunk

              "The New ITA Global popover on the right opens with the last information I attempt to add, but the record is never added nor are the globals cleared."

               

              That would indicate either that the globals don't have global storage specified in field options or this script is not actually being performed.

               

              If you have FileMaker Advanced, test your design with the script debugger enabled so that you can see which scripts are executing and step through them while using the data viewer to monitor the values in fields and variables.

               

              The way relationship lines "connect" to table occurrence boxes take the form of a tee, a single line or "crowsfeet " depending on the field options specified so these didn't look right to me. But after checking a solution with ESS tables this seems normal and thus not a problem.

              • 4. Re: Related Record via a Popover
                llweisscptc

                "That would indicate either that the globals don't have global storage specified in field options or this script is not actually being performed."

                 

                Yes, the field all indicate storage as globals.

                 

                I will check them with the script debugger.

                 

                If the script isn't being performed what would be the issue?

                For the globals popover - I have the script on the add ITA button on the popover which is on the OnObjectExit script trigger.

                Is it on the incorrect trigger?

                There is no trigger on the New ITA global button that opens the popover.

                 

                thanks

                • 5. Re: Related Record via a Popover
                  philmodjunk

                  Hard to say without examining a copy of your file. But your script clearly clears the global fields so I listed the ways that would keep them from being cleared.

                   

                  An OnObjectExit trigger, BTW, would need to be specified for the popover's panel and not it's button in order for that script to run when the popover closes.

                  1 of 1 people found this helpful
                  • 6. Re: Related Record via a Popover
                    llweisscptc

                    "An OnObjectExit trigger, BTW, would need to be specified for the popover's panel and not it's button in order for that script to run when the popover closes."

                     

                    That was the issue.

                    I should have posted weeks ago, but I attempt to figure stuff out on my own. Lesson learned.

                     

                    A big thanks.

                    • 7. Re: Related Record via a Popover
                      BeatriceBeaubien

                      Thanks to philmodjunk for this. I was asked for this behaviour (in a different use case, but related) from a user last week and thought it might entail some working through and testing different script triggers but the suggestion worked first time.

                       

                      Best wishes,

                       

                      Beatrice