Many solutions make use of script-based forms, based on the Form Script functionality, and there is a common need to map form data to and from local databases.
The Form Data Script simplifies this mapping. The form data script relies on additional rules held in the form definition to understand the mapping. Once these are in place, using the form data script is simple.
To create a form data instance, use.
var formData = new FormData(database,form);
Where database is a database instance object, and form is a form definition. (This is the "raw" form defintion, not an instance of the Form class defined in Form Script.)
To save form data to the database, use.
formData.put(data);
Where data is the form's data.
To get form data from the database, use.
var data = formData.get(keys);
Where keys contains the business keys of the row represented as form data.
Form fields are mapped to the fields used on the row using mapping rules. The default mapping rule is simply to copy the form field to the row on put, and to copy the row field to the form on get. Additional rules are used to specify the table, get and put services, different row field names, and nested objects or repeating groups. See Form Data Script for details of the mapping rules.