Editar

Compartilhar via


Session.UnbindSubscription(Codeunit) Method

Version: Available or changed with runtime version 1.0.

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

Syntax

[Ok := ]  Session.UnbindSubscription(Codeunit: Codeunit)

Note

This method can be invoked without specifying the data type name.

Parameters

Codeunit
 Type: Codeunit
The codeunit that contains the event subscribers.

Return Value

[Optional] Ok
 Type: Boolean
true if the event subscriber methods unbind successfully to the codeunit instance and no errors occurred, otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.

Remarks

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

Calling this method on a codeunit that hasn't been bound (by the BindSubscription Method) will result in an error. If the call to this method is successful, all bindings are removed.

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

Example

The following sample code illustrates a typical use of the BindSubscription method.

Method 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;  
  

Session Data Type
Get Started with AL
Developing Extensions