1 Reply Latest reply on May 28, 2012 3:24 PM by erolst

    Using a script trigger to Set Field

    m.bodily.consulting

      Can anyone help me Set Field By Name according to the last active record on a different table?

      I have a field called CheckoutDate on the CheckOut layout. OnObjectValidate I want to launch a script trigger which changes/sets a different field, called patronID, to the last active record on the previous layout, CirculationDesk.

      This is how I got my script started:

      • Set Field By Name [Master::patronID]
      • I'm stumped on what the calculation would be. The calculation would need to retrieve the last active record on the CirculationDesk layout so that it could be put in the target field (patronID).

      The CirculationDesk and CheckOut layouts have a common field named Full_Name. (is that info needed?)

        • 1. Re: Using a script trigger to Set Field
          erolst

          If you know which field to set, you can use plain old Set Field [].

           

          • Go to Layout ( CirculationDesk )

          • Set Variable [ $patronID ; <yourFieldName> ]

          • Go to Layout [ original layout ]

          • Set Field [ Master::patronID ; $patronID ]

           

          From your other post (scripting), I have the suspicion that some (all?) of your layouts are based on the same TO.

          If the CheckOut layout is based on the same TO as CirculationDesk, then the active record is the same

          on both layouts, since layouts with the same TO have the same found set, and switching from one to the

          other doesn't change the active record (or the found set).

           

          In this case you wouldn't even have to change layouts, but then I would think your data model is somewhat flawed.

          I gather this is a library database. Are your books, patrons, checkouts etc. all in the same table?