AL icon indicating copy to clipboard operation
AL copied to clipboard

Uninstall codeunit

Open Joerio opened this issue 8 years ago • 7 comments

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?

Joerio avatar Dec 21 '17 10:12 Joerio

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 avatar Dec 21 '17 15:12 waldo1001

@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?

bwdeleeuw avatar Dec 21 '17 16:12 bwdeleeuw

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

Joerio avatar Dec 22 '17 09:12 Joerio

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.

vytjak avatar Dec 27 '17 11:12 vytjak

'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.

ghost avatar Dec 27 '17 17:12 ghost

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.

pzentner avatar Jan 23 '18 11:01 pzentner

This suggestion is tracked as part of #191 - closing as duplicate.

StanislawStempin avatar Feb 07 '18 10:02 StanislawStempin