3 Replies Latest reply on Jan 22, 2012 10:25 AM by Sorbsbuster

    Add User Script - User already exist error

    MikeTrotter

      Title

      Add User Script - User already exist error

      Post

      I have a user table in my solution with a "create new system user" layout. I have fields for the appropriate items in the table on the layout. I have a script that does some very simple validation and then saves the record. After saving the record, it runs the "Add Account" script step.

      When it runs that, I get a 'user already exists" error, however the user info is still created in both the table and in the FM accounts.

      As usuall this newbie finds that the error is usually something super simple, but I'm stuck.

      Help please... I have attached a grab of the script.

       

      Thanks,

      Mike

       

      script.jpg

        • 1. Re: Add User Script - User already exist error
          Sorbsbuster

          I would clarify that the seccond test fails because the user hasn't entered any password, and the third test fails because they don't match.  Are you not going to use the User Role to create the account with a differing Privilege Set, rather than all users being created as Data Entry?  If the scripts fails any of the tests I would also clear the data entered so far, just to be tidy and secure.  Maybe you haven't shown all the script, but at what stage is the new record with the new user created?  Or are these fields all global fields and effectively over-write any previous entries?  Are you keeping a table with all the users and passwords in it?

          Now having made some points were not at all about your question... I can only suggest that the warning is correct, and you already do have that user in your file.  I notice that you don't have any check to see if the user exists already (and I believe you would do that by maintaining a table of all custom-added users and checking there.)

          You could try adding a custom dialogue just before the Add Account step and showing the account name it is about to add.  You might be surprised that it is picking up data you didn't expect - perhaps because of a missing 'new record' step.

          • 2. Re: Add User Script - User already exist error
            MikeTrotter

            Good points on my rather week validation scripts. The user role in this solution will not be used (at this point) for privilege sets, everyone added through this script will be data entry only. I actually have two scripts for this routine. The first script opens a new window, goes to the data entry layout linked to my user table and performs a "new record/request". The user then enters all the info for the new user and when he presses the "create new user" button, the script above runs. I finally figured out what the stupid problem was...

            I didn't add a "close window" step to the above so, when I clicked the "create user" button, nothing happened visually so I was clicking it again without even realizing it and thus trying to create the user again. As you said "the warning is correct".

            New lesson learned!

            Thanks for the help Sorbsbuster.

            • 3. Re: Add User Script - User already exist error
              Sorbsbuster

              I would look at why you need to open another window, and bring upon yourself all the management problems that has.  Just offer the user a custom dialogue with global fields to capture the input.  Far, far, easier.

               And be careful with 'Exit script' as opposed to 'Halt script'.  Using 'Exit...' will carry on with whatever the next script call is...