8 Replies Latest reply on Jan 8, 2013 12:58 PM by philmodjunk

    Allowing Delete Records

    EP

      Title

      Allowing Delete Records

      Post

           I normally diasable the ability to delete records from users privilege sets. However, I have a solution where I use the delete record in a script (when a user accidentally adds a record via a popup, they have the abiity to Cancel, which runs a delete record script).  This helps keeo the database clean.  In order for this to work, I have to give users the option to delete records. In my startup script, I set the status toolbar to OFF and LOCK, so I think I'm safe from users mailiciously/accidentally deleting all records/existing records.  Anyone advise against this? 

        • 1. Re: Allowing Delete Records
          philmodjunk

               The key board shortcut for delete record still works when the status area is hidden/locked. But you can disable delete records in the privilege set and use a script set to run with "full access privileges" to delete records.

               You can also collect user input in global fields and not create a new record until after the user clicks submit--performing a script that creates a new record and transfers the data from the global fields to the corresponding fields of the new record.

          • 2. Re: Allowing Delete Records
            Abhaya

                 I think the 2nd one is better than the 1st.

                 We may take a global to keep the ID and after submit button is clicked it will add a new record on that table.

            • 3. Re: Allowing Delete Records
              EP

                   Thanks I implemented the first temporarily.  I think the second method is the way to go long term.  How would is be implemented?  Would i simply create a bunch of globals including a foreign key global which a user would fill out and when they press the "ok" button a script would run with Set Field functions to transfer the data from the globals to the actual fields?

              • 4. Re: Allowing Delete Records
                philmodjunk

                     Yes, that's the basic idea. You can switch the user to a layout with these fields or even use new window to pop it up as a dialog box for them to complete.

                • 5. Re: Allowing Delete Records
                  EP

                       Yea I already have a popup window.  I'd just need to replace the fields with the new globals.  How exactly do globals work when it comes to serials?  I'm assuming there isn't a conflict with foreign keys, but some of my table have foreign and parent keys......wouldn't the parent keys fight/conflict if multiple users are creating a record?

                  • 6. Re: Allowing Delete Records
                    philmodjunk

                         The values in global fields are specific to a given user. Values entered into a global field by one user will not be seen by other users.

                         I'm not sure what you are asking about when you say "when it comes to serials". Exactly what do you mean by that?

                    • 7. Re: Allowing Delete Records
                      EP

                           I mean how is serialing handled for my parent keys on the global fields layout....if the pk is stored in a global field, and ten users are entering new records, how do the serials increment without conflict? As I'm typing this I think I figured it out...is this correct: create a script that pops up a new window navigating to a layout with the global fields.  When the user is finished and clicks an OK button, then a script runs with a New Record command and set fields to populate the corresponding fields?  If this is correct is there a command that "clears" the global fields when leaving the layout?

                           Thanks

                      • 8. Re: Allowing Delete Records
                        philmodjunk

                             You are correct. You wouldn't store the PK in any global field. When your script creates a new record, then the serial number field that you already have will auto-enter a value as it is already set up to do.

                             You can use series of set field steps to clear each global field after you have created the record and transferred the data, or you can do the same in the script that first pops up this window.

                             Set Field [Yourtable::GlobalField ; "" ]

                             clears that one field.