3 Replies Latest reply on Oct 5, 2014 8:44 AM by philmodjunk

    Do scripts triggered by data events need a layout?

    besmith1ca

      Title

      Do scripts triggered by data events need a layout?

      Post

      First, let me qualify myself by disclosing I'm a total newbie and am getting ready to develop my first script.

      This script is going to be triggered by the creation of a new record in a specific table.  When a new record is created, the script will parse that record into various fields located in three other tables.

      Do I need to create a layout for this script to operate?

        • 1. Re: Do scripts triggered by data events need a layout?
          philmodjunk

          And what trigger will you use that will be tripped by the creation of a new record? How will the new record be created? (There's no specific trigger that you can select to be tripped by the creation of a new record, OnRecordLoad might possibly be used for such--depending on how the new record is being created.)

          All scripts operate from the "context" of the current layout's table occurrence. Some script steps interact directly with layout objects and thus require that the current layout contain the objects in question. The "insert" script steps are examples of that. Others interact directly with the underlying table. Set Field is the most commonly used example of that type of script step. Both work from the context of the current layout so if you need to create new records in other tables to receive the data that you are parsing, the relationships in place may or may not make that possible and it is often necessary to use go to layout to change layouts in order to change context.

          This is not a simple answer to your question, is it?

          You may want to describe what you want to do and the design of your layout in more detail so that we can respond with more detailed responses to your question.

          • 2. Re: Do scripts triggered by data events need a layout?
            besmith1ca

            Thank you!

            Being such a newbie, you gave me a couple clues that helped tremendously.  For example, I didn't realize there was no trigger for record creation.  That sent me to researching the list of available triggers.  Now I see what my options are and I'm off and running, designing my process around available triggers.

            I'm all set for now.  Thanks again! 

            • 3. Re: Do scripts triggered by data events need a layout?
              philmodjunk

              How to use OnRecordLoad to respond to the creation of a new record (and only the creation of a new record):

              Add a field, (I'll call it "NewRecFlag"), that auto-enters a serial number. This field can NOT be used as a primary key in many cases. Select the "Generate: On Commit" option for it.

              Set up your OnRecordLoad trigger to run this script:

              If [ IsEmpty (YourTable::NewRecFlag) // you have a newly created record not yet committed]
                Do the stuff here that you need to do when a new record is committed.
              Else
                Do the stuff here (if anything) that should take place any time a record that is not newly created becomes the current record
              End IF
              Do the stuff here that should take place every time this trigger is tripped for either a new or an existing record