Working With Data Records

In many application scenarios standard view panels can handle almost all application functionality, from retrieving the data records from the server, to displaying them, to handling user input, to saving updated records to the database. Typically, you only need to program interaction between panels, for example calling edit form refresh() method when the user selects another node in the tree panel.

In some cases you might need to write custom JavaScript code to access and process the data records directly to:

  • Retrieve data records from the server
  • Perform mathematical or logical operations on the data
  • Display the data using custom HTML controls
  • Update data values based on users' input
  • Save the updates to the database.

The data records retrieved from the server and used by standard controls are represented by the Ab.data.Record object. The record values are stored as JavaScript objects, such as Date, Number or String.

As a general rule, in the application, JavaScript code should operate on JavaScript objects and not exclusively on string values. The String data type should not be used to represent numeric or date/time values in calculations or business logic. The application code should not operate on strings formatted for the user interface controls, or on values formatted for the client-to-server data transfer.

When you use Web Central JavaScript API to work with data records, the conversion between Archibus-neutral strings, JavaScript objects, and localized strings, happens automatically. In most cases your application code only needs to work with JavaScript objects.

Even though Web Central uses JSON format and Archibus-neutral strings to transfer all data values between the client and the server, the Ab.data.Record.getValue() and Ab.data.Record.setValue() accept and return JavaScript objects.

Even though the user interface controls display localized strings, the Ab.form.Form.getRecord() and Ab.form.Form.setRecord() accept and return records with JavaScript objects.

Ab.data.Record methods:

Name Description Parameters
new Ab.data.Record( values, isNew) For records that are sent to the server, an isNew value of true indicates that the record does not exist in the database yet.

values : JavaScript object containing named record values;

isNew : true to mark this record as "new";

getValue(name) Returns object value of specified record field. name : field name;
setValue( name, value) Sets object value of specified record field.

name : field name;

value : value as a JavaScript object;