3 Replies Latest reply on Dec 27, 2013 8:18 AM by philmodjunk

    Having trouble with Add New Record Script



      Having trouble with Add New Record Script


           I'm trying to have a way for users to add a new record without giving access to any other records.  I have a button on the users main screen that runs this script.


      Script - Add New Senior Record


      Set Error Capture [On]

      New Window [Name: “Add New Senior”; Height: 565; Width: 625; Top: 50; Left: 50; Style: Dialog]

      Go to Layout [“Add New Senior Record” (Seniors)]

      Show/Hide Toolbars [Hide]

      New Record/Request

      Commit Records/Requests [No dialog]

      Go to Field [Seniors::_fk_SchoolCode]


           After they input the data they click either the "Add Record" Button and the following script runs 


      Script:  Commit Record and Close Window


      Commit Records/Requests [No dialog]

      Close Window [Current Window]



           OR  they press the  "Cancel DO NOT ADD RECORD"  button and the following script runs


      Script:  Cancel New Record


      Delete Record/Request [No dialog]

      Close Window [Current Window]


           This works ok until someone (like me) opens the layout and presses the "Cancel DO NOT ADD RECORD" at which time a valid record is deleted from the database.


           Is there an easy way to know if a new record was in fact created before deleting so I don't inadvertently delete records from the database?  Or is there a better way to do this altogether?







        • 1. Re: Having trouble with Add New Record Script

               A "new" record will contain data identical to an existing record. Your script to open a new window could set a "flag" field to a value and your save button could clear that field so that it is no longer marked as "new". Then your delete record script could check the value of that field before deleting a record.

               But you also might also just set up a set of global fields for entering the data for the new record. Then your "save" script creates the new record and transfers the data from the global fields to corresponding data fields in the new record. Then there is no new record to delete when a user "cancels", the script just clears the global fields.

          • 2. Re: Having trouble with Add New Record Script

                 Thanks Phil,

                 I like the idea of creating global fields but the first field on the layout is a lookup from another table of schools we have contracts with and the second field has logic so it is only entered if the school field is "other" i.e. a school we don't have a contract with.  I don't have a clue how to do that with global fields…or if it is even possible.

                 I'll give the setting a "flag" solution a try first.

                 Thanks again…you are always so helpful,


            • 3. Re: Having trouble with Add New Record Script

                   It is definitely possible to set up your "lookup" using a global field.