Validation required -only single use of each number allowed in a text feild using Louts script

In My application form i have text feild where the multiple number are entered.I need the validation in such a way that only single use of each number allowed in the text feild using Louts script

Please help me to solve the issue

Regards

Sruthi

Subject: Validation required -only single use of each number allowed in a text feild using Louts script

  1. The field must be a multi-value field.

  2. Call the function below in QuerySave like this:

continue = checkDups(fldname)

  1. Here is the function (there are several ways to do this)

function checkDups(fname as string)

'doc is a global of type NotesDocument

dim item as notesitem

dim flag as integer, idx as integer

dim searchArray () as string

flag = True

set item = doc.GetFirstItem(fname)

'Loop through the values in the field

forall m in item.values

  'Look for the value in the search array

  if idx > 0 then



      if ArrayGetIndex(searchArray, m) > 0 then

         messagebox "Error:  Too many " & m & "'s" 

         flag = False

         exit for

      end if



  end if



  'Dynamic array, increase the size preserving the values.

  redim preserve searchArray(0 to idx)



  'Save the field value in the array.

  searchArray(idx) = m



  idx = idx + 1

End Forall

checkDups = flag

end function

Note: I did not test this but it is pretty close. Essentially each value in the field is stored in an array and then the array is used for searching.

Subject: RE: Validation required -only single use of each number allowed in a text feild using Louts script

shame is has to be in script since it would only be one line of code in @Formula

@If(@Sort(fname) = @Sort(@unique(fName));@Success;@Failure(“Failure:yadiyadiya”))