Server Events
Copy
onBeforeSyncAdd
Overview
The onBeforeSyncAdd server event:
- Runs before an Item is added to the database during synchronization.
- Is called per Item.
- Can be used to populate some data with values that have not been passed from the Source System or to add local values, e.g., values for fields created_by_id and managed_by_id.
- Runs before required onBeforeAdd events (with @is_required=1).
- The dss_syncAdd request may be rejected completely by returning an error from this event handler.
Input/Output arguments
This event is called per Item. The request Item with the assigned ID is passed to the event handler as a Context Item (inDom). No additional event arguments are passed to the handler.
The context Item of onBeforeSyncAdd event handlers with all the changes applied to it inside the handlers is passed further as a Context Item to the onBeforeAdd event handlers.
The return results of onBeforeSyncAdd event handlers are ignored, unless there is an error. In this case the dss_syncAdd is stopped and the error is returned in the action response.
onAfterSyncAdd
Overview
The onAfterSyncAdd server event:
- Runs after an item has been added to the database during synchronization
- Runs after required onAfterAdd events (with @is_required=1).
- Is called per Item.
- Can be used to propagate the synchronized Items to external systems if required, e.g., for Mixed Federated Items.
Input/Output arguments
Unlike the onAfterAdd Server Event, onAfterSyncAdd Server Event handlers don’t get the created Item as the Context Item. The event handler’s Context Item is empty. The details about the created Item are provided in event arguments of type OnAfterSyncAddEventArgs:
public class OnAfterSyncAddEventArgs
{
public string TypeId { get; }
public string Id { get; }
}
If required, the event handlers can load the item from the DB themselves using the type and ID.
The return results of onAfterSyncAdd event handlers should be ignored, unless there is an error. In this case the dss_syncAdd should be stopped and the error should be returned in the action response.
onBeforeSyncUpdate
Overview
The onBeforeSyncUpdate event:
- Runs before an Item is updated in the database during synchronization.
- Runs before the required onBeforeUpdate event (@is_required=1).
- Can be used to populate some data with values that have not been passed from the Source System or should be adjusted to local values, e.g., values for fields created_by_id and managed_by_id.
- Is called per Item.
- The request may be rejected by returning an error.
Input/Output arguments
If the request Item contains a where condition or idlist, the condition is resolved to a list of Item IDs and the event handlers are called per each Item ID.
The request Item with the condition replaced with the Item ID is passed to the event handler as a Context Item (inDom). Table 5 shows an example.
Table 4: A request Item example
| Request AML | OnBeforeUpdate Context Items |
<Item type="SyncedItem” idlist="50DD6F18D7E14791965914314B1E156C, 5459D4256BAB4639AF564186A5174E93" action='dss_SyncUpdate'> | <Item type='SyncedItem’ id='50DD6F18D7E14791965914314B1E156C’ action='dss_SyncUpdate'> |
<Item type='SyncedItem’ id='5459D4256BAB4639AF564186A5174E93' action='dss_SyncUpdate'> |
The context Item for onBeforeSyncUpdate event handlers with all the changes applied to it inside the handlers are passed further as a Context Item to the onBeforeUpdate event handlers.
In addition to the Context Items, the onBeforeSyncUpdate event handlers receive event arguments of type OnBeforeSyncUpdateEventArgs that contain a list of all the IDs in the entire as well as the ItemType ID:
public class OnBeforeSyncUpdateEventArgs
{
public string TypeId { get; }
public IEnumerable<string> IdList { get; }
}
The return results for onBeforeSyncUpdate event handlers are ignored, unless there is an error. In this case that dss_syncUpdate is stopped and the error is returned in the action response.
onAfterSyncUpdate
Overview
The onAfterSyncUpdate event:
- Runs after an item has been updated in the database during synchronization.
- Runs after a required onAfterUpdate event (@is_required=1).
- Runs once for the whole Item set in the request.
- Can be used to propagate the synchronized Items to external systems if required, e.g., for Mixed Federated Items.
Input/Output arguments
The event handler’s Context Item is empty. The updated Items aren’t loaded. The details about the updated Items are provided in the event arguments of type OnAfterSyncUpdateEventArgs:
public class OnAfterSyncUpdateEventArgs
{
public string TypeId { get; }
public IEnumerable<string> IdList { get; }
}
If required, the event handlers can load the items from the database themselves using the type and ID list.
The return results of onAfterSyncUpdate event handlers are ignored, unless there is an error. In the case of an error, the dss_syncUpdate is stopped, the request transaction is rolled back, and the error is returned in the action response.