formData.model
(FintechOS Studio 20.1.1 and later)
Provides read/write access to the values of the form fields of the current record's attributes. If you update a form field value, it will be saved in the corresponding record attribute when the form is saved.
In versions prior to 24.2, formData.model only interacts with the currently displayed form fields, not with the data model. Therefore, if an attribute is not displayed in the current form, you cannot retrieve it using the formData.model method.
Starting with release 24.2, you can operate on attributes that are not rendered in the user interface. However, an attribute field still needs to be present in the UI (e.g.: hidden attributes), otherwise its value will not be recorded when saving the form or flow.
To retrieve attribute values from the database, see ebs.getFormEntity.
Retun Value
Returns a JSON object containing key-value pairs for the current record's attribute names and attribute values, for example:
{
"businessStatus": {
"_id": "c33e87bd-763f-4cf0-8a73-c860e8a96747",
"_name": "status1"
},
"businessStatusId": "c33e87bd-763f-4cf0-8a73-c860e8a96747",
"businessUnitId": "a3d2909b-df67-49d6-b7e0-2dc912c12484",
"createdByUserId": "4afdc8a9-eb91-4359-81d6-c3a462fae866",
"createdOn": "2020-03-02T15:15:37.000Z",
"elapsedTime": null,
"file": null,
"method": null,
"modifiedByUserId": null,
"modifiedOn": null,
"nextBusinessStatusId": null,
"previousBSId": null,
"ServerSDKTestid": null,
"entityStatusId": null,
"userId": null
}
You can use the dot notation or bracket notation to access individual record attributes, for example:
formData.model.elapsedTime
or
formData.model['elapsedTime']
Examples
In this example, we track the duration in milliseconds between the time when a form is opened and the time the final form step (the Thank You screen) is displayed.
In the first form step's afterGenerate.js script, we define a variable called start that holds the current time:
formData.setAdditionalValue('start', new Date());
For details on how to define an object that can be accessed in subsequent form steps, see formData.setAdditionalValue.
In the last form step's afterGenerate.js script, we save the duration in milliseconds passed since the first form step was opened in the elapsedTime attribute of the current record.
formData.model.elapsedTime = (new Date() - formData.getAdditionalValue('start'));
For details on how to read an object that was defined in a preceding form step, see formData.getAdditionalValue.