sir/madaam, using formula language what validation formula that will return an error if a user enter the same value that is already exist in a view column…
thank you
sir/madaam, using formula language what validation formula that will return an error if a user enter the same value that is already exist in a view column…
thank you
Subject: validation
You need to give a bit more info on the view, but I think basically what you’re looking for is a comparison with a dblookup, so try something like:
@if(@contains(@implode(@dblookup(“”:“NoCache”;“”;“Viewname”;key;comlumnnumber));Fieldvalue);@failure(“Contains the same value”);@success)
hth
Dan
Subject: RE: validation
Hm. It’s not quite that simple. You have to take into account whether this is a new document, since for an existing document, we would expect to find the value already there.
Also, must check for errors.
Also, don’t use @Contains here.
Something like this:
@If(@IsDocBeingSaved; “”; @Return(@Success));
_tmp := @DbLookup(“”:“NoCache”;…; [RETURNDOCUMENTUNIQUEID]);
@If(@IsError(_tmp); @Success;
@Text(_tmp) != @Text(@DocumentUniqueID); “A document with key "” + @Text(fieldname) + “" already exists.”;
@Success)
Haven’t tried this specific formula, but seems like it should work.
Subject: I stand corrected. Cheers Andre
Subject: Not bad, but you can avoid the lookup for existing docs by…
@If(@IsDocBeingSaved & @IsNewDoc; “”; @Return(@Success));T1 := @DbLookup(“”;“”;“ViewSortedByYourField”; YourField; 1);
@If(@IsError(T1); @Success; @Failure("Value already exists: " + YourField))
Subject: I don’t want to avoid the lookup for existing docs.
Original question didn’t specify to only check on create. What if they change the field value and after the change, it’s the same as another existing document?
Subject: True.