Uninstall codeunit
We currently have the option to write an install codeunit (subtype = install) where we can do some logic when installing the extension.
I have some code that for example registers a new webservice when installing this extension, this stays in the table when uninstalling the extension. I would like to clean up these kinds of remains when uninstalling my extension.
I can't find if there is such a thing as a codeunit that runs when uninstalling an extension. Can this currently be done, or are there plans to implement this in the future?
You should not insert a webservice with the install codeunit, but work with an XML - file in your extension. That way, it will uninstall automagically.
xml should like like this
<?xml version="1.0" encoding="utf-8"?>
<ExportedData>
<TenantWebServiceCollection>
<TenantWebService>
<ObjectType>5</ObjectType>
<ServiceName>YourWebService</ServiceName>
<ObjectID>50100</ObjectID>
<Published>true</Published>
</TenantWebService>
</TenantWebServiceCollection>
</ExportedData>
@waldo1001 I'm trying to find documentation on this, but I can't seem to find it. Could you point me in the right direction?
Thanks, i'm going to try this solution. I found some more information about this now I knew what to search for, if someone else needs this too: https://docs.microsoft.com/en-us/dynamics-nav/how-to-export-data-for-an-extension https://docs.microsoft.com/en-us/powershell/module/microsoft.dynamics.nav.apps.tools/export-navapptenantwebservice?view=dynamicsnav-ps-2018
While we do not have an immediate need for this, I do think the possibility to add custom uninstall logic would be a useful one. +1 for this.
'Uninstall' code is being actively developed and should work in a similar fashion as Install & Upgrade code. (e.g. codeunit subtype = uninstall). No specific ETA, but we are working it out.
Just wanted to add my 2 cents to it. This is actually a blocker for us to move forward with some of the v2 conversions due to not being able to remove conditions when the extension is uninstalled and then it will leave the standard system in an inconsistent state.
This suggestion is tracked as part of #191 - closing as duplicate.