--- title: "Replication Script Editor" slug: "replication-script-editor" updated: 2024-03-28T14:24:59Z published: 2024-03-28T14:24:59Z canonical: "skthelp.syniti.com/replication-script-editor" --- > ## Documentation Index > Fetch the complete documentation index at: https://skthelp.syniti.com/llms.txt > Use this file to discover all available pages before exploring further. # Replication Script Editor Use this editor to write a script that is run when a specific event occurs during replication. The script should consist of one or more functions selected from the drop-down lists at the top of the Editor. The drop-down list on the left displays the categories for which you can define an event handler. The Editor provides [editing and formatting features](/docs/replication-script-editor#Editing_and_Formatting_Features) that include automatic indentation, automatic coloring for syntax, numeric values, comments, "code folding", and keyboard shortcuts. | Category | Events | Event Type | Explanation | | --- | --- | --- | --- | | Refresh | [onBeforeTruncate](/v1/docs/replication-script-events#refreshonbeforetruncate) [onAfterTruncate](/v1/docs/replication-script-events#refreshonaftertruncate) [onBeforeRefresh](/v1/docs/replication-script-events#refreshonbeforerefresh) [onAfterRefresh](/v1/docs/replication-script-events#refreshonafterrefresh) [onPrepareRefresh](/v1/docs/replication-script-events#refreshonpreparerefresh) | [Writer](/v1/docs/managing-reader-and-writer-events-in-a-script) [Writer](/v1/docs/managing-reader-and-writer-events-in-a-script) [Writer](/v1/docs/managing-reader-and-writer-events-in-a-script) [Writer](/v1/docs/managing-reader-and-writer-events-in-a-script) [Reader](/v1/docs/managing-reader-and-writer-events-in-a-script) | Available events apply to refresh replications only. | | LogReader | [onPrepareMirroring](/v1/docs/replication-script-events#logreaderonpreparemirroring) [onBeforeMirroring](/v1/docs/replication-script-events#logreaderonbeforemirroring) [onAfterMirroring](/v1/docs/replication-script-events#logreaderonaftermirroring) [onReceiverChanged](/v1/docs/replication-script-events#logreaderonreceiverchanged) | [Reader](/v1/docs/managing-reader-and-writer-events-in-a-script) [Reader](/v1/docs/managing-reader-and-writer-events-in-a-script) [Reader](/v1/docs/managing-reader-and-writer-events-in-a-script) [Reader](/v1/docs/managing-reader-and-writer-events-in-a-script) | Available events apply only to mirroring and synchronization replications. onReceiverChanged applies only to replications involving System i/iSeries/AS400. | | Record | [onBeforeMapping](/v1/docs/replication-script-events#recordonbeforemapping) [onAfterMapping](/v1/docs/replication-script-events#recordonaftermapping) [onBeforeExecute](/v1/docs/replication-script-events#recordonbeforeexecute) [onAfterExecute](/v1/docs/replication-script-events#recordonafterexecute) | [Reader](/v1/docs/managing-reader-and-writer-events-in-a-script) [Reader](/v1/docs/managing-reader-and-writer-events-in-a-script) [Writer](/v1/docs/managing-reader-and-writer-events-in-a-script) [Writer](/v1/docs/managing-reader-and-writer-events-in-a-script) | Available events apply to each record that is considered for replication. In the case of refresh replications, the events would apply to every record in the source/target table. In the case of mirroring and synchronization replications, the events would apply to records found in the transaction log. | | Replication | [onConflict](/v1/docs/replication-script-events#replicationonconflict) [onLateConflict](/v1/docs/replication-script-events#replicationonlateconflict) | [Reader](/v1/docs/managing-reader-and-writer-events-in-a-script) [Reader](/v1/docs/managing-reader-and-writer-events-in-a-script) | onConflict and onLateConflict should be used to [resolve conflicts](/v1/docs/resolving-conflicts-during-synchronization) only for synchronization replications. | The right drop-down list displays a list of appropriate [events](/v1/docs/replication-script-events) for which you can write a script. If no function was selected from the left side, the list remains empty. The default Visual Basic template content of the Replication Script Editor looks as follows. However, it is possible to write the script using C# instead of Visual Basic by setting the scripting language in the [Global Script Editor](/v1/docs/global-script-editor), accessible from the right mouse button menu on the metadata. ```plaintext Imports Microsoft.VisualBasic Imports DBMotoPublic Imports DBMotoScript Imports DBRS.GlobalScript Namespace DBRS     Public Class ReplicationScript : Inherits IReplicationScript     End Class End Namespace ``` When you choose an event to add to the script, it is always added directly below the ReplicationScript class as in the example below. ```plaintext Imports Microsoft.VisualBasic Imports DBMotoPublic Imports DBMotoScript Imports DBRS.GlobalScript Namespace DBRS     Public Class ReplicationScript : Inherits IReplicationScript         Public Overrides Sub Record_onBeforeMapping(recSource As IRecord, ByRef AbortRecord As Boolean)                      End Sub     End Class End Namespace ``` Add code to manage the event. You can include functions from other libraries in the script code, but be sure to add the library to the list of Imports, add the library location using the References dialog and set up a namespace for the library. You can access the References dialog by clicking ![](https://cdn.document360.io/ca09b4e9-1857-4c63-9f0e-1f25f166f447/Images/Documentation/b852ccd7-cd32-4580-b659-7f8b7ff17e51.png?sv=2026-02-06&spr=https&st=2026-11-17T19%3A21%3A00Z&se=2026-11-17T20%3A21%3A00Z&sr=b&sp=r&sig=OCflbUr2yfkkTF9TkmnnbldKjpYZFB1ajzOzppqb%2FnU%3D) in the toolbar below the script. | ![](https://cdn.document360.io/ca09b4e9-1857-4c63-9f0e-1f25f166f447/Images/Documentation/CompileIcon (3).png?sv=2026-02-06&spr=https&st=2026-11-17T19%3A21%3A00Z&se=2026-11-17T20%3A21%3A00Z&sr=b&sp=r&sig=3a8kO06DBo08xsZ1osO1r3C2FS6brfSfZa0ITa5Saaw%3D) | Checks the script syntax. If you do not do this in the script editor, you may encounter errors when the replication is running. | | --- | --- | | ![](https://cdn.document360.io/ca09b4e9-1857-4c63-9f0e-1f25f166f447/Images/Documentation/ExpressionGeneratorButton (2).png?sv=2026-02-06&spr=https&st=2026-11-17T19%3A21%3A00Z&se=2026-11-17T20%3A21%3A00Z&sr=b&sp=r&sig=xA%2B4PY3Ixm8PsR4eE64LHcNSqBEGGGGjKStR374ngcE%3D) | Opens the [Expression Generator](/v1/docs/expression-generator) | | ![](https://cdn.document360.io/ca09b4e9-1857-4c63-9f0e-1f25f166f447/Images/Documentation/b852ccd7-cd32-4580-b659-7f8b7ff17e51.png?sv=2026-02-06&spr=https&st=2026-11-17T19%3A21%3A00Z&se=2026-11-17T20%3A21%3A00Z&sr=b&sp=r&sig=OCflbUr2yfkkTF9TkmnnbldKjpYZFB1ajzOzppqb%2FnU%3D) | Opens the References dialog so that you can add the location of any dlls that you are using from your script. You typically need to add dlls to the References dialog and to the script Imports when they do not belong to the default Microsoft .NET environment. | | ![](https://cdn.document360.io/ca09b4e9-1857-4c63-9f0e-1f25f166f447/Images/Documentation/CommentSelectionIcon (1).png?sv=2026-02-06&spr=https&st=2026-11-17T19%3A21%3A00Z&se=2026-11-17T20%3A21%3A00Z&sr=b&sp=r&sig=ldKI0Sh2TXDywbpYLuJSYXdLY21ZT4JMejREjXExCNQ%3D) | Creates a comment for selected text | | ![](https://cdn.document360.io/ca09b4e9-1857-4c63-9f0e-1f25f166f447/Images/Documentation/UncommentSelectionIcon_27x27 (1).png?sv=2026-02-06&spr=https&st=2026-11-17T19%3A21%3A00Z&se=2026-11-17T20%3A21%3A00Z&sr=b&sp=r&sig=Ps9UdqCKH5m%2FkNhgpgbk1W1QWAsjuQOhh1%2BZQN4KnuM%3D) | Uncomments selected text | ## Editing and Formatting Features - Automatic indentation based on syntax - Colors to identify specific code elements: syntax in blue, numeric values in pink and comments in green - Code folding where sections of code can be collapsed or expanded for ease of reading. The editor displays a green bar on the left side with +/- signs. Click - to collapse a section of code, and click + to expand a section of code. - Common editing operations using keystroke combinations: | Left, Right, Up, Down, Home, End, PageUp, PageDown | Move caret with selection | | --- | --- | | C V X | Copy, paste, cut | | A | Select all text | | Z, Y | Undo/Redo | | Tab Tab | Increase/decrease left indent of selected range | | Home End | Go to first/last char of the text | | Home, End | Go to first/last char of the text with selection | | U U | Convert selected text to upper/lower case | | | Switch between Insert Mode and Overwrite Mode | | Backspace Del | Remove word left/right | | Mouse, Up, Down, Right, Left | Enable column selection mode | | Up Down | Move selected lines up/down | | Del | Remove current line | | | Close all opened tooltips, menus and hints | | Wheel | Zoom | | Up Down | Scroll Up/Down | | NumpadPlus, NumpadMinus 0 | Zoom in, zoom out, no zoom | ## Opening the Replication Script Editor On the [Replication Properties dialog](/v1/docs/replication-properties-dialog) General tab, check the Use Script option. Click **Script** to open the Replication Script Editor. **Related Topics** [Writing Scripts with Visual Basic .NET](/v1/docs/writing-scripts-in-syniti-replicate) [Writing a Replication Script](/v1/docs/writing-a-replication-script) [Replication Script Events](/v1/docs/replication-script-events) [Replication Script Properties](/v1/docs/replication-script-properties)