1 Reply Latest reply on Jul 1, 2011 9:23 AM by philmodjunk

    Go to Portal Row (Last) -- issues

    firth5

      Title

      Go to Portal Row (Last) -- issues

      Post

      I have a portal that sorts the related records by Creation Timestamp in descending order, so the newest record is always on top.

      I have a script written as such:

      Go To portal row [select; Last]

      Insert Text [select; FIELD1; "Text"]

      ----

      When performing the script, the text just overwrites the same row, every time.  What am I doing wrong?

      thanks!

        • 1. Re: Go to Portal Row (Last) -- issues
          philmodjunk

          Is there more than one portal on your layout?

          If so, the focus may be on the other portal instead of the one you want the script to interact with.

          The fix for that is to use the name box at the top of the Inspector's position tab to give the portal an object name. Then use:

          Go to Object ["PortalNameHere"]
          Go to Portal row....

          Also, is "Allow creation of records via this relationship" enabled for the portal relationship? If it's not, you'll need to enable that option in Manage |Database|Relationships or your script will simply overwrite the bottom existing row of data each time instead of adding a new record.

          I'd also use Set Field instead of Insert Text for this. Insert Text only works if the field is physically present on the layout while set field does not so I make a habit out of never using insert script steps except for cases where set field won't work such as inserting files into container fields or when the data to be inserted or the target field receiving the data is controlled by the cursor position.

          It's also a bit safer to switch to a layout based on your portal's table then switch back to your original layout to display the results. That keeps any future layout changes from breaking your script.

          Freeze Window
          Set Variable [$ID ; ParentRecord::PrimaryKeyfield]
          Go To Layout [portal table layout]
          New Record/Request
          Set Field [PortalTable::ForeignKeyField ; $ID ]
          Set Field [Portaltable::Field1 ; "Text"]
          Go To Layout [original layout]