computeWithForm (NotesDocument - JavaScript)

Validates a document by executing default value, translation, and validation formulas, if any are defined in the document form.

Defined in

NotesDocument

Syntax

computeWithForm(dodatatypes:boolean, raiseerror:boolean) : boolean
Parameter Description
dodatatypes The method ignores this parameter. Specify either true or false.
raiseerror If true, an error is raised if the validation fails. If false, no error is raised; instead, the method returns false if validation fails.
Return value Description
true if there are no errors in the document
false if there are errors in the document

Usage

The form is as follows:
  • The form stored in the document, if any.
  • The value of the Form item, if no form is stored in the document.
  • The database default form, if the document does not have a Form item.

In the user interface, you must use a form to create a document. The document must meet the form requirements for input validation, and the user interface informs you if the document does not meet these requirements. Programmatically you can create a document without a form. The computeWithForm method provides a means of checking that the data you placed in a document meets the requirements of a form, although (unlike in the user interface) you can still save a document if computeWithForm returns false or throws an exception.

Examples

The following button verifies a new document against the ???main??? form before saving.
var doc = database.createDocument();
doc.appendItemValue("Form", "main");
doc.appendItemValue("Subject", requestScope.query);
if (doc.computeWithForm(false, false)) {
	doc.save();
	requestScope.status = "Document saved";
} else {
	requestScope.status = "Input verification failed";
}