{"title":"Session.UnbindSubscription(Codeunit) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/session/session-unbindsubscription-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/session/session-unbindsubscription-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/session/session-unbindsubscription-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Unbinds the event subscriber methods from in the codeunit instance.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Session.UnbindSubscription(Codeunit) Method","slug":"sessionunbindsubscriptioncodeunit-method","at":0,"chars":2108},{"level":2,"title":"Syntax","slug":"syntax","at":253,"chars":152},{"level":2,"title":"Parameters","slug":"parameters","at":405,"chars":110},{"level":2,"title":"Return Value","slug":"return-value","at":515,"chars":306},{"level":2,"title":"Remarks","slug":"remarks","at":821,"chars":424},{"level":2,"title":"Example","slug":"example","at":1245,"chars":728},{"level":2,"title":"Related information","slug":"related-information","at":1973,"chars":135}],"text":"# Session.UnbindSubscription(Codeunit) Method\n> Version: _Available or changed with runtime version 1.0._\nUnbinds the event subscriber methods from in the codeunit instance. This essentially deactivates the subscriber methods for the codeunit instance.\n## Syntax\n```al\n[Ok := ]  Session.UnbindSubscription(Codeunit: Codeunit)\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nCodeunit\nType: ../codeunit/codeunit-data-type\nThe codeunit that contains the event subscribers.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue 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.\n## Remarks\nYou can only call this method on codeunits that have the ../../properties/devenv-eventsubscriberinstance-property set to Manual.\nCalling this method on a codeunit that hasn't been bound \\(by the session-bindsubscription-method\\) will result in an error. If the call to this method is successful, all bindings are removed.\nThe codeunit instance that is unbound will be the same instance that previously was bound.\n## Example\nThe following sample code illustrates a typical use of the BindSubscription method.\n```al\nMethod MyFunction(….)\nLocalVar\n  SubScriberCodeunit5000;\nbegin\n  // Set global information on the subscriber codeunit if required\n  // You can rely on the instance being the same as the one receiving the event subscriber call\n\n  SubScriberCodeunit5000.MySetGlobalInfo(<info you can later test in the subscriber event method>)\n  BindSubscription(SubscriberCodeunit5000);\n  DoSomething(…);  // After binding, all subscriptions on SubscriberCodeunit5000 are \"active\".\n  UNBindSubscription(SubscriberCodeunit888);  // Now deactivating again\n  DoStuff(…);  // This time no events are raised inside SubscriberCodeunit888;\n\nend;\n\n```\n## Related information\nsession-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}