2 Replies Latest reply on Apr 7, 2010 5:59 PM by Radcon

    YAPRQ: yet another portal relationship question

    Radcon

      Title

      YAPRQ: yet another portal relationship question

      Post

      Hi ya'll,

      I have set up portals on two different tabs of a layout.  The portals display records from a related history table that stores snapshots of the data on the two tabs.  A script creates new records in the history table based on script triggers firing from the two layouts when certain data are changed.  What I am not getting is why my key field is not populated automatically as if I were creating a new record from the portal( I don't want to create new history records from the portals, view only).  I scripted around this by defining a local variable to my key field, and then setting that value in the newly created history record.  This doesn't seem like the best solution; what am I missing? ( And what did I leave out in describing this?)

       

      Thanks!

        • 1. Re: YAPRQ: yet another portal relationship question
          philmodjunk

          "( And what did I leave out in describing this?)"

          describing your portal relationship and whether "allow creation of records via this relationship" is enabled for the portal side of the relationship  would help.

           

          Posting your scripts that attempt to log records in this related table would help also.

           

          From your description, I think you are attempting to create a related record with a script step like this:

           

          Set Field [History::Field ; Expression]

           

          From your Parent table's layout.

           

          But I could be wrong.

           

          If that's what you are trying to do, it works either once or not at all depending on whether you've enabled the above "allow creation..." option. Outside of a portal this creates a new record if there are no related records for the current parent record if the "allow creation..." option is enabled. IF there are related records, this step attempts to modify the first such related record and thus fails to create a new related record.

           

          If you don't select the "allow creation... " option, nothing at all happens.

           

          You have two main choices:

           

          1. Interact with your related records through the portal by entering text in the bottom blank row of the portal with the "Allow creation" option enabled--this can be by hand or in a script.
          2. Use a script that creates a new record in the history table and also assigns it the necessary matching value from the parent record:

          Set Variable [$ID ; MainTable:: PrimaryKeyField]

          Go To Layout [PortalTableLayout]

          New Record/Request

          Set Field [PortalTable::ForeignKeyField ; $ID]

           

          (You can add more set field instructions to load your new record with data as needed.)

           

          • 2. Re: YAPRQ: yet another portal relationship question
            Radcon

            Hi Phil,

            Thanks for your patience and willingness to help.  The script I used was nearly identical to what you suggested in (2).  I will sort through other parts of your reply and get you more information later when I am back at my dayjob desk.  Thanks again!