4 Replies Latest reply on Mar 30, 2012 7:45 PM by jamroman

    Unique Account name

    jamroman

      Title

      Unique Account name

      Post

      Users in my database create an account name.  Can someone help me with a script that will kick a user out if they try to create an account name that already exists?

       

      Thanks,

      James

        • 1. Re: Unique Account name
          philmodjunk

          Won't they get an error if they try that? (if, so youmight be able to trap for that error.)

          On the other hand, if you set up a script that creates a record with the account name in a table in your database each time a new account is created, your script can compare the account name entered in a global text field against these records to see if that account name already exists. A script can perform a find or you can set up a relationship that matches the global field to the account name in order to check for a pre-existing account with the same name.

          • 2. Re: Unique Account name
            jamroman

            An error message does pop up, "This name is already in use. Please provide a unique user name."  The problem is that the user can proceed within the record of the original user--a security problem.  

            My script looks like (where user name is a text calculation):

            If [Get (AccountName)=UserNameCalc]

                Go to Layout ["User Error Page" (May)]

            Else

                Go to Layout ["User Password Entry Page" (Password)]

                New Record/Request

                Add Account[]

            End if

             

            Thanks,

            James

            • 3. Re: Unique Account name
              philmodjunk

              I was thinking of a script like this--but keep in mind that I haven't tested it:

              Set Error Capture [on]
              Create Account [AccountName: YourTable::GlobalAccountNameField ; Password: YourTable::GlobalPasswordField ; PrivilegeSet: "PrivilegeSetname" ]
              If [ Get ( LastError ) ≠ 0 // error occurred creating account. ]
                 Show Custom Dialog [ "Please use a different account name" }
              End If

              Such a script would need to be run with the "run with full access privileges" setting.

              • 4. Re: Unique Account name
                jamroman

                Phil,

                For this, and all your prior responses to my questions, you are a filemaker Sensai.

                Thanks,

                James