Hi ,I need to write a code in which if i entered a data in a form which is exactly simililar to the previous data entered in the form (save in the db.)then it will display some messege.so I have to apply a field input validation logic.Could u please help me in this.
Subject: input field validation
You need a view that is sorted by the value in the field – then you can use @DbLookup in the validation formula:
@If(@IsError(@DbLookup(“”; “”; “ViewName”; @ThisValue; 1)); @Success; @Failure(“There is already a document in the database for this value.”))
Subject: RE: input field validation
Having had so much fuss about @DbLookup and caching, this would actually be a good place to use the “NoCache” option.
Also, whenever doing a validation of this kind, having a suitable input translation in place is probably a good idea, especially when text is entered. You don’t want to a user to circumvent your check just by adding an additional blank, so at least something like
@Trim(@ThisValue)
is almost a no-brainer for the input translation. If appropriate, even additional stuff like @ProperCase may have it’s use, but that depends a lot on how much flexibility you must grant your users.
Subject: Also…
Check if the result is not the document itself. Otherwise you won’t be able to change the document!
One way to do it:
Put @Text(@documentUniqueId) in the 2nd column of your view
Validation code:
checkId:=@text(@DocumentUniqueId);
check:=@DbLookup(“”; “”; “ViewName”; @ThisValue; 2);
@If(@IsError(check); “”; @If(checkId!=check;@Return(@Failure(“There is already a document in the database for this value.”));“”));
@success