Formatting and Parsing Data Values

When working with standard panels, you can directly pass the records between DataSources and panels. Any required formatting or conversion will happen automatically:

var record = this.requestDataSource.getRecord();
...the record contains JavaScript objects...

this.requestForm.setRecord(record);
...the form displays localized values...

...the user can change values...

record = this.requestForm.getRecord();
...the record contains updated JavaScript objects...
this.requestDataSource.saveRecord(record);


If you are implementing custom UI controls, you will need to write the code to format data record values so that they are displayed using the correct locale for the current user. You will also need to write the code to parse values entered by the user.

For data records that are retrieved from the DataSource you can use formatting/parsing methods provided by the Ab.data.DataSource object:

  • Format an object value as a localized string:

var dateRequested = record.getValue('wr.date_requested');
var uiValue = this.requestDataSource.formatValue('wr.date_requested', dateRequested, true);

  • Parse UI control localized string into an object value:

var uiValue = ...
var dateRequested = this.requestDataSource.parseValue('wr.date_requested', uiValue, true);
record.set('wr.date_requested', dateRequested);

The values can be formatted/parsed as long as their names (such as ' wr.date_requested ') match data source fields declared in AXVW. The DataSource formatting/parsing API is based on Archibus schema field definitions, and cannot be used to format/parse values that do not match data source fields.

To format/parse values which are not managed by Archibus schema, you can use a third-party library such as Ext.JS. The Ext.Date.format() and Ext.Date.parseDate() allow you to format or parse date and time values:

  • Format an object value as a localized string:

var today = Date();
var uiValue = today.format(View.dateFormat);

  • Parse UI control localized string into an object value:

var uiValue = ...
var date = Ext.Date.parseDate(uiValue, View.dateFormat);

The View. dateFormat and View.timeFormat properties contain user locale-specific date (time) format patterns which are set automatically when the view is loaded.