Unbinds the event subscriber functions from in the codeunit instance. This essentially deactivates the subscriber functions for the codeunit instance.

[OK:=] UNBINDSUBSCRIPTION(Codeunit)

Parameters

Codeunit

Type: Codeunit

The codeunit that contains the event subscribers.

Property Value/Return Value

Type: Boolean

true if the event subscriber functions unbind successfully to the codeunit instance and no errors occurred; otherwise false.

If you omit this optional return value and the operation is not successful, then a run-time error occurs. If you include the return value, then you must handle any errors.

Remarks

You can only call this function on codeunits that have the EventSubscriberInstance Property set to Manual.

Calling this function on a codeunit that has not been bound (by the BINDSUBSCRIPTION Function) will result in an error. If the call to this function is successfull, all bindings are removed.

The codeunit instance that is unbound will be the same instance that previously was bound.

Example

The following code illustrates a typical use of the BINDSUBSCRIPTION function.

 Copy Code
Function MyFunction(….)
LocalVar
  SubScriberCodeunit5000;
BEGIN
  // Set global information on the subscriber codeunit if required
  // You can rely on the instance being the same as the one receiving the event subscriber call
  SubScriberCodeunit5000.MySetGlobalInfo(<info you can later test in the subscriber event method>)
  BINDSUBSCRIPTION(SubscriberCodeunit5000);
  DoSomething(…);  // After binding, all subscriptions on SubscriberCodeunit5000 are “active”.
  UNBINDSUBSCRIPTION(SubscriberCodeunit888);  // Now deactivating again
  DoStuff(…);  // This time no events are raised inside SubscriberCodeunit888;
END; 

See Also