Anywhere API Reference – BusinessModel

Main page of the Anywhere API Reference

Defines standard event handlers for ModelData objects.

onInitialize(obj)

This method is automatically invoked by the Anywhere platform when a record is loaded into a ModelDataSet.

It is typically used to set non-persistent attributes default values.

Parameters

  • obj – The ModelData object being loaded

Examples

onInitialize : function(workOrder) {
  workOrder.set("locationdesc", workOrder.get('maxlocationdesc'));
  workOrder.set("assetdesc",
  workOrder.get('maxassetdesc'));
}

onAdd(obj)

This method is automatically invoked by the platform when a record is added into a ModelDataSet.

It is typically used to set attributes default values.

Parameters

  • obj – The ModelData object being added

Examples

onAdd : function(workOrder) {
  // set siteid to the user's default
  workOrder.set("siteid", UserManager.getInfo("defsite"));
}

beforeSave(obj)

This method is automatically invoked by the Anywhere platform when a record is added into a ModelDataSet.

It is typically used to perform validations or set additional field upon save.

Parameters

  • obj – The ModelData object being saved

Examples

beforeSave : function(obj) {
  var startdate =
obj.getAsDateOrNull('startdate');
  if (!startdate)
    throw new
PlatformRuntimeException('startdateisrequired');
  ...
} beforeSave : function(obj) {   obj.set('createby',UserManager.getCurrentUser()); }
Scroll to top