2 Replies Latest reply on Oct 1, 2009 12:50 PM by philmodjunk

    Delete Script

    thong127

      Title

      Delete Script

      Post

      Hello to everyone,

       

      kindly check my script if which part I need to be changed.

       

      Show Custon Dialog ["You Want to delete all your data?"; "Enter your password"; Products:: Field Password]

      If[Exact(Product::Field Password; Products::Delete All)]

         Show Custom Dialog ["Warning All your data will be Deleted."]

         If[Upper(products::Field Password)=Product::Delete All and Get(ActiveModifierKeys)=2]

      Else

        Delete All Rcords[]

         Show Custom Dialog ["Message All Records Successfully Deleted"]

        End If

      End If

      Show Custom Dialog["Message"; Password is Incorrect"]

       

       

      Thank you very much.

       

      Best Regards,

       

      Thong

       

        • 1. Re: Delete Script
          MikeyG79
             I'm not a fan of deleting information. What about making a "status" field that could hold say active or inactive. Then your Delete script could change the flag rather than delete records.
          • 2. Re: Delete Script
            philmodjunk
              

            The Structure of the If steps seem strange.

             

            As posted, the script will permit deleting all records in the found set If a matching password is entered correctly, but not if the password is all caps and the caps lock is depressed (The upper function does not effect results here since the test is true only if caps lock is down). Then, at the end, a custom dialog tells the user that the password was incorrect even if, in fact, it was entered correctly.

             

            I suggest simplifying the system by using accounts and privileges to control which user is able to delete records. Then, rewrite your script to be:

             

            If [ get (privilegesetname) = "[Full access]" ]

               Show custom dialog ["Do you want to delete all records in the found set?"]

               IF [ get ( lastmessagechoice ) = 1 /* User clicked first button, labeled "Yes" */]

                   Delete All Records [No Dialog]

               End If

            Else

               Show Custom Dialog ["Your password does not permit you to delete all records in the found set"]

            end if