When I test a form, an error appears saying: field not found in index. I also encounter an error: this function is inappropriate for file system directories. What should I do?
I believe the error you're getting is actually "Entry not found in index." This happens because a field on the form has macro code that uses @DbLookup. The call to @DbLookup returns an error because the key is not found in the view. Most likely the reason the key is not found in the view is because you are reading the key from a field on the form -- and the field does not yet contain a value. Since the value "" does not appear in the view, you get an error.
When you use @DbLookup, you should always test the returned value to see whether it is an error. For example, instead of:
@DbLookup(""; ""; "someView"; keyField; 2)
you might write:
@IfError(@DbLookup(""; ""; "someView"; keyField; 2); "")
For greater efficiency, you might test the key field first and not bother to do the lookup if it's blank.
@If(someField = ""; ""; @IfError(@DbLookup(""; ""; "someView"; keyField; 2); ""))
Do you have comments on this Ask the Expert question and response? Let us know.