Writing Scripts

Syniti Data Replication supports three types of scripts:

  • Global scripts
    A global script is a shared module that defines a global class of functions. It can be used to define general user functions that need to be called from inside a replication script or an expression script.

  • Replication scripts
    A script that is defined to run when a specific event occurs during replication.

  • Expression scripts
    A script used in the Mapping Dialog when a column value needs to be mapped not simply to a source column but to a value retrieved after calculation.

Syniti DR scripts can be written using C# or Visual Basic .NET. C# is the default scripting language for all script types. However, it is possible to change the scripting language for a specific metadata in the Global Script Editor.

Changing the Script Language

To change the script language for all scripts associated with a metadata:

  1. In the Metadata Explorer, select the metadata.

  2. From the right mouse button menu, choose Global Script.

  3. In the Global Script Editor, change the language in the Script Language drop down list.

Note that any scripts already saved in a Script Editor will become commented code when the script language is changed.

Visual Basic .NET Tips for Developers

Note that, while there are many similarities between Visual Basic and Visual Basic. NET, there are also some subtle differences. For information about the Visual Basic .NET language, see http://msdn.microsoft.com/vbasic/using/

  • Use IsNothing in place of Visual Basic's IsNull

  • Always use parentheses for the arguments of a function, even if there are no arguments

  • Always use typed parameters. Define the return type of your functions.

  • In a global script, define all custom procedures (Subs and Functions) using the keyword ’Shared’, in order to define them as static functions.

  • Always compile a script before executing it. The VB.NET compiler is stronger than the old VBA compiler and it is able to find errors at an earlier stage.

  • The way Syniti DR numbers the columns of the record is not necessarily the same as the order of the source or target columns. For example, if some fields are not mapped, they are excluded from the RecordBefore or RecordAfter structure and so the columns are not numerically matching their ordinal number.