11 Replies Latest reply on Nov 21, 2016 1:43 PM by philmodjunk

    Script for unique Value

    oumayma

      hi ,

      I need the script unique value the field  

      for example if user enter the name is already exist in  database It shows  him  error 

      thnx

        • 1. Re: Script for unique Value
          philmodjunk

          No script needed for that.

           

          You can set up a unique values validation on the name field in Field Options.

           

          But sometimes two people have exactly the same name. You may need to consider that possibility as you design this part of your solution.

          • 2. Re: Script for unique Value
            oumayma

            addexist.PNG

            but after user click  yes ,Accept it, despite it exists

            scriptunique.PNG

            This was used but did not work

            thanks

            • 3. Re: Script for unique Value
              philmodjunk

              You can change another setting to prevent a user from overriding the validation error.

               

              There are also many other approaches that can help keep the user from making a data entry error in the first place.

               

              The name field, for example could be formatted with an auto-complete value list of names. The user would know right away that the name they are entering already exists or if it is unique. You might even modify your design so that duplicate names (but with unique ID's) can be used in your system.

               

              Once again, you have made a very brief post with very little information to work with in order to provide a useful answer to you.

              • 4. Re: Script for unique Value
                coherentkris

                Agree with PMJ here.

                The setting you want is in the validation settings to prevent user override.

                they resultant dialog will only have the option to revert.

                This is data protection so the solution closest to the data layer is the first place you should try to implement it.

                Scripting a solution can work but it is easy to miss something and allow data mistakes.

                • 5. Re: Script for unique Value
                  oumayma

                  I need the script because i want to show message error in field not the message box

                  I hope that will help me in the script correction

                  • 6. Re: Script for unique Value
                    oumayma

                    I need the script because i want to show message error in field not the message box

                    I hope that will help me in the script correction

                    • 7. Re: Script for unique Value
                      philmodjunk

                      Then please provide a much more detailed description of what you are trying to do. Please put it in terms of the overall task that is being performed here as there are many ways to do what you request.

                      • 8. Re: Script for unique Value
                        keywords

                        "i want to show message error in field not the message box"—

                        The only way I can think of to get this outcome is to set up an auto-enter calc within the field to evaluate what is entered, accept it if it's OK, and post an error message otherwise. Something like this:

                         

                        Let (

                        [

                          textEntered = Self

                        ; OK = evaluation Calc checking textEntered to see if it fits criteria // this will return 1 or 0

                        ; result = If ( OK ; textEntered ; textEntered & " is not unique; try again" ) // this will post the text with the error message if it fails the test

                        ] ;

                        result

                        )

                        • 9. Re: Script for unique Value
                          oumayma

                          hi ,

                          help me pleaaase can you Send me a layout that contains (let) , which you said

                          pleaaaaaaaaase

                          • 10. Re: Script for unique Value
                            oumayma

                            can you explain more

                            • 11. Re: Script for unique Value
                              philmodjunk

                              You wouldn't put it on a layout. What Keywords has recommended would be part of the field's definition.

                               

                              Go To Manage | Database | fields

                               

                              Find the table your field is defined in.

                               

                              Double click that field definition.

                               

                              Select the Auto-Enter tab

                               

                              Click the calculation option and paste the expression recommended by Keywords into that calculation editor.

                               

                              Click OK as needed to close dialogs and save your work, but be sure to clear the "do not replace existing value (if any)" check box before closing the field options dialog.