Last modified on 25 September 2026, at 09:31

Use Change Detection via Change Notifications

In UBIK® 4, there is a mechanism for the automatic detection of changes by other UBIK® processes, which provide notifications for their changes.

Configuration

The UBIKContent web service can be configured to react to such notifications by updating its cache; mostly the user group cache used for rights evaluation.
Change detection can be configured in the application settings of the UBIKContent web service.

IC Hint square.png

When EnableChangeNotifications is disabled, calculated properties that depend on linked objects may not be updated immediately across different UBIK sessions.

Changes made to a linked object in another session may not be reflected until the affected object is reloaded.

Enable EnableChangeNotifications to ensure that changes are propagated across sessions and dependent calculated values are updated automatically.

Customizing

There are multiple possibilities to react to change detections via customizing.

Overriding the event handler of an instance

protected virtual void OnBeforeUpdateByChangeNotification()
{
    // Called before an already cached instance will be reloaded from the database because of a change notification.
}

protected virtual void OnAfterUpdateByChangeNotification()
{
    // Called after an instance was reloaded from the database because of a change notification.
}

Attaching a new event handler to the UBIKEventManager

// In Plugin code or custom code library, or anywhere else:

UBIK.Kernel.UbikEventManager eventMan = Environment.GetEventManager();
eventMan.InstanceAfterUpdateByChangeNotification += EventMan_InstanceAfterUpdateByChangeNotification;
eventMan.InstanceBeforeUpdateByChangeNotification += EventMan_InstanceBeforeUpdateByChangeNotification;
// Don't forget to unregister from the events when the handlers are not needed anymore, to avoid a memory leak:
// eventMan.InstanceAfterUpdateByChangeNotification -= EventMan_InstanceAfterUpdateByChangeNotification;
// eventMan.InstanceBeforeUpdateByChangeNotification -= EventMan_InstanceBeforeUpdateByChangeNotification;

// ...

private void EventMan_InstanceBeforeUpdateByChangeNotification(BaseClass sender)
{
    // Act before imminent reload, for example:
    // InvalidateState(sender);
}

private void EventMan_InstanceAfterUpdateByChangeNotification(BaseClass sender)
{
    // React to change, for example:
    // UpdateCache(sender);
}

See also