TDABusinessRuleScript

Overview

TDABusinessRuleScript provides the Business Rules Scripts base class which defines specific rules and actions to validate data input, without having to hard-code this logic into the client and server application.

With business rules scripts, the server can provide the business logic in form of Pascal language scripts as part of the schema, which will then be executed on the client using RemObjects Pascal Script 3.0 (included with Data Abstract).

TDABusinessRuleScript is used by the TDADataset class. To fill a script text correctly, we recommend to use Schema Modeler:

  • Open it via the TDASchema component.
  • Select a data table.
  • Select the "Businness rules" command on the "Data Tables" pane.

The simple script:

procedure BeforeDelete;
begin
  if Gain > 50 then
    RaiseError('Cannot delete orders that make us more then 50$');
end;

procedure BeforePost;
begin
  if VarIsNull(ProductID) then
    RaiseError('Please specify a name.');
    
  if Quantity < 1 then
    RaiseError('Quantity can not be less 1 !');

  if UnitPrice < 10 then
    Quantity := 10;
end;

procedure OnCalcFields;
begin
  Gain := UnitPrice*Quantity*(1-Discount);
end;

procedure OnNewRecord;
begin
  Quantity := 1;
end;

Location


 

Assign  override

Copies data from a given source.

procedure Assign(Source: TPersistent)

Parameters:

  • Source: Instance whose properties will be copied

Clear  virtual

Clears all properties.

procedure Clear

Description

Sets or gets a new description. It can be any user information.

property Description: string read write

Script

Sets or gets a script code.

property Script: CDATAString read write

ScriptLanguage

Sets or gets a current script language. For now it only supports one value rslPascalScript. Please refer to the Pascal Script help topic for more details.

property ScriptLanguage: TROSEScriptLanguage read write

ScriptLanguageStr

Current script language.

property ScriptLanguageStr: string read write

 

Description

Sets or gets a new description. It can be any user information.

property Description: string read write

Script

Sets or gets a script code.

property Script: CDATAString read write

ScriptLanguage

Sets or gets a current script language. For now it only supports one value rslPascalScript. Please refer to the Pascal Script help topic for more details.

property ScriptLanguage: TROSEScriptLanguage read write

ScriptLanguageStr

Current script language.

property ScriptLanguageStr: string read write

 

Assign  override

Copies data from a given source.

procedure Assign(Source: TPersistent)

Parameters:

  • Source: Instance whose properties will be copied

Clear  virtual

Clears all properties.

procedure Clear