9 Replies Latest reply on Jun 1, 2012 10:39 AM by Sorbsbuster

    Delete selected records

    tays01s

      Title

      Delete selected records

      Post

      I can see how youi delete individual or all records but not how you could say delete record 1, 3, 5-7, 14 simultaneously of 20 records. Cmd and Shift +click don't appear to have the 'usual' effect of allowing multiple selection. Is there a way of doing  this?

        • 1. Re: Delete selected records
          Sorbsbuster

          Not that I know of.  The only way I do that is use Cmd-T and Cmd-Shift-T to omit and omit multiple the ones I want to keep, then Delete All for the remainder.

          • 2. Re: Delete selected records
            tays01s

            Thanks.

            Strange there isn't a method......probably for a reason I can't think of!

            • 3. Re: Delete selected records
              philmodjunk

              Some developers create their own controls for selecting a record. The method that works best/simplest can be different depending on whwther you need to support a multi-user environment where two or more users might be selecting records at the same time or not.

              • 4. Re: Delete selected records
                tays01s

                Is there an example I could see?

                • 5. Re: Delete selected records
                  philmodjunk

                  As a developer where I am currently the only user, I often use Sorbuster's method, but if you have other users that might be creating new records at the same time another user is selecting multiple records, that method could, if the timing is just exactly wrong, result in deleting the other user's newly created record as that newly created record can appear as an omitted record and then be included in the delete.

                  Do you want a selection method for a single user environment or one where multiple users might be selecting and deleting multiple records at the same time?

                  • 6. Re: Delete selected records
                    tays01s

                    Single user would probably suffice.

                    • 7. Re: Delete selected records
                      Sorbsbuster

                      (Phil - "could [...] result in deleting the other user's newly created record as that newly created record can appear as an omitted record and then be included in the delete."

                      I was suggesting "to omit and omit multiple the ones I want to keep, then Delete All for the remainder.")

                      • 8. Re: Delete selected records
                        philmodjunk

                        @Sorbsbuster,

                        Apologies for not reading more carefully. As far as I know, that approach is safe to use in multi-user systems. The reverse is pretty safe too for small numbers of records as long as you pay attention to what you have on your screen before deleting the records.

                        @Stephen Taylor,

                        A simple method only "safe" in single user systems is to add a field to your table and use it to "mark" the fields you want to delete.

                        This could be a single value check box where you click each check box of the records you want to select. Then your "delete selected" script would find all records with a value in this field and delete them.

                        It's possible to use scripts that detect that the shift key is down, so you could use a button where its script saves the record number of the first record clicked while marking it, if the shift key is not down. If the shift key is down, the script marks all keys from the saved record number to the record where you just shift clicked and you then have selected a range of records to delete.

                        This method doesn't work well in multi-user systems as it will find and delete all marked records--whether selected by you or another user. Thus, a user could mark a record for deletion and have it mysteriously disappear just before they tried to clear the checkbox having changed their mind about deleting it.

                        In multi-user systems, you can use a button with a script that builds a list of record serial numbers in a global field or variable. This provides each user with their own specific list of selected records and conditional formatting can show selected records as being marked for selection. A script then uses the list of serial numbers to find the records and delete them.

                        One final note: Some developers use a method like this, but never actually delete the records. They just use a field like this to mark deleted records as deleted and then design scripted finds, relationships, portal filters and such to hide the "deleted" records from view. With this approach, when a user comes to you hat in hand and says "I deleted a record by mistake, is there any way to undelete it?", You can smile, find the record, clear the delete value and "presto", the record magically reappears on the user's screen.

                        • 9. Re: Delete selected records
                          Sorbsbuster

                          We use Phil's global-field-list to manage user-selected lists like this.  And as he also suggests, may be good never to actually delete records.  Off-hand I can't think of any table we allow the users to truly delete from.  In some cases the 'delete' button actually exports it to an archive table, then deletes it.  That avoids having to remember to append conditions to user's searches, for excample.