4 Replies Latest reply on Feb 5, 2017 7:02 PM by philmodjunk

    Create New 'Related' Record in Popover

    lcot17

      Hi -

       

      I was wondering if someone could possibly spend 5 minutes with me to walk me through the following problem:

      How to create a new / go to a record of a related table in a popover?

       

      I have a 'Customers' table and a 'Customers Log' table.

      In the customers table, I have a portal showing the related records from the 'Customers Log' table.

       

      I would like to:

      1) Click a 'Add to Log' button to open a popover > create a new record with the CustomerIDpk set > and allow me to enter the data into that record from the popover > click a save button to commit the record.

      2) Click a record in the 'Customer Log' portal table > this opens that related record in the popover.

       

      Currently my issue is that I have a loop where script triggers are executing over and over again creating an infinite number of empty log records. I know theoretically that it is because I am not correctly disabling script triggers - but practically I am not 100% on how to do it.

       

      I need to know how to:

      1. Correctly set a global field for $$scriptTrigger = "on" ?
      2. How to structure the scripts and triggers and what 'on load / on open / on exit' to set them on?
      3. What is the content of each script that I require in order to make this work?

       

      Effectively - as a practical example - the 'Invoices' starter solution. When on the 'New Invoice' layout I select a customer > click on New Customer. I would like that functionality to both create a new customer log and to also view the customer log data for a record I click in the list.

       

      Screen Shot 2016-02-26 at 20.33.50.png

       

      Screen Shot 2016-02-26 at 20.36.15.png

        • 1. Re: Create New 'Related' Record in Popover
          bigtom

          I would use a non animated slide panel in the popover. Each panel needs an object name. One displays your existing log entries and the other has a single row portal and go to portal row last for entering your new records.

           

          Tthe trigger is on the pop over itself and not the button.

           

          I would pass a parameter of "new" with the add button that will drive you to the correct slide panel via script.

          • 2. Re: Create New 'Related' Record in Popover
            bigtom

            scracth that. Since it is a dedicaTed popover for adding a log you don't need the slider or the parameter. The only thing you need is a trigger for a script to got to the last portal row for entry. Assumes you have record creation via relationship enabled.

            • 3. Re: Create New 'Related' Record in Popover
              dangelsaurus

              isn't "Go to Portal Row [Last]" going to close the popover immediately though?

              • 4. Re: Create New 'Related' Record in Popover
                philmodjunk

                To disable script triggers I set a global variable, $$TriggersOff to True. I put this code at the beginning of every script performed by a script trigger:

                 

                if [$$TriggersOff ]

                   Exit Script [.  ]

                End If

                 

                To add related records from the context of the pop over, I recommend using a method known as MagicKey. You can research this term to learn the details. It's advantage here is that the popover can remain open while the script adds the related record.

                 

                You can place global fields to the popover for entering data that can be used to create/edit the new related record. An edit button in the portal row can transfer data to the globals and the portal record's ID to the the MagicKey match field. This way, the same script that creates a new related record updates the record selected for editing instead.