--- title: "Handling Events for INSERT, UPDATE and DELETE Operations" slug: "handling-events-for-insert-update-and-delete-operations" updated: 2024-03-28T17:56:42Z published: 2024-03-28T17:56:42Z canonical: "skthelp.syniti.com/handling-events-for-insert-update-and-delete-operations" --- > ## 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. # Handling Events for INSERT, UPDATE and DELETE Operations When writing an event-handling function for a replication, you often need to consider which type of operation (INSERT, UPDATE, DELETE) is being performed during the replication. In your [replication script](/v1/docs/writing-a-replication-script), use the record's [OperationType](/v1/docs/irecord-interface#operationtype-property) property to identify the type of operation being performed, as in the following VB.NET example. ```plaintext Public Overrides Sub Record_onAfterMapping(recSource As IRecord, recTarget As IRecord, By Ref AbortRecord As Boolean)  if (recSource.OperationType = enmOperationType.Update)      AddLog(recSource.GetValueBefore(0), 0)  End if End Sub ``` Depending on the operation type, different functions for accessing source and target values are available. ## INSERT Operations **Replication Types**: Refresh (all records) and mirroring/synchronization (insert operations obtained from the transaction log) **Record Functions Available**: | Source Record | Target Record | | --- | --- | | [GetValueAfter(index)](/v1/docs/irecord-interface#getvalueafter) | [GetValueAfter(index)](/v1/docs/irecord-interface#getvalueafter) | | [GetValueAfter(col)](/v1/docs/irecord-interface#getvalueafter) | [GetValueAfter(col)](/v1/docs/irecord-interface#getvalueafter) | | [SetValueAfter(index, value)](/v1/docs/irecord-interface#setvalueafter) | [SetValueAfter(index, value)](/v1/docs/irecord-interface#setvalueafter) | | [SetValueAfter(col, value)](/v1/docs/irecord-interface#setvalueafter) | [SetValueAfter(col, value)](/v1/docs/irecord-interface#setvalueafter) | > [!NOTE] > Note > > Depending on the event function you are using, source or target record objects may not be available. Check the parameters for the event to see which objects you can use. ## UPDATE Operations **Replication Types**: Mirroring/synchronization (update operations obtained from the transaction log) **Record Functions Available:** | Source Record | Target Record | | --- | --- | | [GetValueBefore(index)*](/v1/docs/irecord-interface#getvaluebefore) | [GetValueBefore(index)*](/v1/docs/irecord-interface#getvaluebefore) | | [GetValueBefore(col)*](/v1/docs/irecord-interface#getvaluebefore) | [GetValueBefore(col)*](/v1/docs/irecord-interface#getvaluebefore) | | [SetValueBefore(col, value)**](/v1/docs/irecord-interface#setvaluebefore) | [SetValueBefore(col, value)**](/v1/docs/irecord-interface#setvaluebefore) | | [SetValueBefore(index, value)**](/v1/docs/irecord-interface#setvaluebefore) | [SetValueBefore(index, value)**](/v1/docs/irecord-interface#setvaluebefore) | | [GetValueAfter(index)](/v1/docs/irecord-interface#getvalueafter) | [GetValueAfter(index)](/v1/docs/irecord-interface#getvalueafter) | | [GetValueAfter(col)](/v1/docs/irecord-interface#getvalueafter) | [GetValueAfter(col)](/v1/docs/irecord-interface#getvalueafter) | | [SetValueAfter(index, value)](/v1/docs/irecord-interface#setvalueafter) | [SetValueAfter(index, value)](/v1/docs/irecord-interface#setvalueafter) | | [SetValueAfter(col, value)](/v1/docs/irecord-interface#setvalueafter) | [SetValueAfter(col, value)](/v1/docs/irecord-interface#setvalueafter) | * Values before an operation are not always available in the log and therefore these functions may return Null. ** These functions are rarely used. > [!NOTE] > Note > > Depending on the event function you are using, source or target record objects may not be available. Check the parameters for the event to see which objects you can use. ## DELETE Operations **Replication Types**: Mirroring/synchronization (delete operations obtained from the transaction log) **Record Functions Available:** | Source Record | Target Record | | --- | --- | | [GetValueBefore(index)*](/v1/docs/irecord-interface#getvaluebefore) | [GetValueBefore(index)*](/v1/docs/irecord-interface#getvaluebefore) | | [GetValueBefore(col)*](/v1/docs/irecord-interface#getvaluebefore) | [GetValueBefore(col)*](/v1/docs/irecord-interface#getvaluebefore) | | [SetValueBefore(col, value)**](/v1/docs/irecord-interface#setvaluebefore) | [SetValueBefore(col, value)**](/v1/docs/irecord-interface#setvaluebefore) | | [SetValueBefore(index, value)**](/v1/docs/irecord-interface#setvaluebefore) | [SetValueBefore(index, value)**](/v1/docs/irecord-interface#setvaluebefore) | * Values before an operation are not always available in the log and therefore these functions may return Null. ** These functions are rarely used. > [!NOTE] > Note > > Depending on the event function you are using, source or target record objects may not be available. Check the parameters for the event to see which objects you can use. **Related Topics** [Global Script Functions](/v1/docs/global-script-functions) [Replication Script Events](/v1/docs/replication-script-events) [Replication Script Properties](/v1/docs/replication-script-properties) [IRecord Interface](/v1/docs/irecord-interface) [Writing a Global Script](/v1/docs/writing-a-global-script) [Writing a Replication Script](/v1/docs/writing-a-replication-script) [Writing Scripts with Visual Basic .NET](/v1/docs/writing-scripts-in-syniti-replicate)