The usage is pretty wide. You can prefill records in a table based on the currently selected records. Even records from another table.
You can use one of the functions in the doo.form
namespace to manipulate with form object:
async openForm(tableNameOrId, options?, applicationId?)
saveAndStay
updateCalculatedFields
Example #1 - options parameter - define and use
const options: IOpenFormOptions = {};
...
await doo.form.openForm(tableName, options);
In parameter options you can fill several properties:
Example #2 - options.model parameter - opens a new form
options.model = {
name: 'Peter',
position: doo.model.preposition.value
}
Example #3 - options.model parameter - opens an edit form - use id
in model
options.model: {
id: doo.model.customer.value.id,
position: doo.model.preposition.value
}
Example #4 - options.header parameter
options.header = 'People';
Example #5 - options.fields parameter - defines this new form
options.fields = <IField[]>[
{
name: 'firstName',
header: 'First name',
order: 10
},
{
name: 'lastName',
header: 'Last name',
order: 20
},
{
name: 'age',
dataType: SchemaColumnDataType.Int,
order: 30
},
{
name: 'profession',
dataType: SchemaColumnDataType.Dropdown,
order: 40,
items: [
{ value: "Actor", order: 10 },
{ value: "Director", order: 20 },
{ value: "Producent", order: 30 }
],
defaultValue: "Actor"
},
{
name: 'location',
dataType: SchemaColumnDataType.Link,
linkedSchemaNameOrId: 'location',
schemaLinkType: DataSchemaLinkTypeEnum.LN21,
order: 50
}
];
Example #6 - options.saveButtonCallback parameter - save values this form to table in application
options.saveButtonCallback = async (params) => {
let fields = {
firstName: params.model['firstName'].value,
lastName: params.model['lastName'].value,
age: params.model['age'].value,
profession: params.model['profession'].value,
location: params.model['location'].value
};
await doo.table.createRecord('people', fields);
return true;
};