error AL0334: Another extension for target ... is already declared in this module.
I am supposing this is by design, but...
I can not do to tableextensions against the same table twice within a single extension. But, since this is of course possible with multiple modules I was surprised by that limitation.
Here's why I would want to use it. Let's say my extension is for a winter shoe store. I have a bunch of related customizations for tracking "shoe" related data on the item: style, size, etc. So this tableextension along with all my other shoe logic objects I put into a folder.
Then maybe we have a bunch of customizations related to rentals: min/max rental days, return policy, etc. I want to put this in another folder with all the rental related objects. Just because they both happen to modify the item, I don't want to put both their logic into the same file.
It seems like this would be allowed if I broke this up into two extensions. But they are designed to work together and complement each other, and I want an easy install. So I'm just wondering about the limitation to only extending a table one time per extension module?
You're right in that this limitation is 'By Design', it is a generic restriction that we've placed on all 'extension' objects within a module. It stems from both the way that extension objects are handled on the server, one such reason being the ambiguity in application order of these objects within a given module. This is particularly true for operations in which the order of modification matters. Take, for example, the following 2 simplified page extension objects:
Existing Object "Some Card"
page 1 "Some Card"
{
Group("Group1")
{
field("Tranquility")
}
Group("Group2")
{
field("Balance")
}
}
pageextension 1 pagextA extends "Some Card"
{
AddAfter("Tranquility") { field("Field1") } // Add after the 'tranquility' control
}
pageextension 2 pageextB extends "Some Card"
{
MoveAfter("Balance", "Tranquility") // Move after the balance control
}
If 'pagextA' is applied first then you would see the following in "Some Card"
Some Card
Group1
Field1 // Field1 added first, when 'name' was here.
Group2
Balance
Tranquility // Tranquility moved after balance
However, if pagextB is applied first, you would see something slightly different
Some Card
Group1 // Nothing left for poor Group1
Group2
Balance
Tranquility // Tranquility moved after balance
Field1 // Field1 added where tranquility is now
While this is also true of multiple separate modules that modify the same sets of objects, we at least want to keep consistency within the same module. (E.g. WYSIWYG, we don't want devs to have to play 'modification order' games to finally see what they expect)
That being said, table extension objects are a little simpler in terms of what/how they can modify their targets and order of application is slightly less important for their non-UI related changes. They could be more amiable to some kind of 'partial' object-ness within a single module that could be merged in a more consistent fashion.
@StanislawStempin is this something we want to consider?
Hey, this design consideration is still a bit unknown so it's affecting how we're structuring our extensions. Have you any new thoughts on it?
To reconcile the problem you're describing of inconsistent UI, maybe you could have a system of some arbitrary, but consistent, tie breakers for the order they are applied in. Like, for example the app guid or object id. Personally, I think that would be a fine trade-off for the ability not to mix multiple basically un-related pieces of code into the same object and file, but, of course I don't know all the considerations.
Taking a different tack - to get around this limitation, we can make multiple extensions. I kind of like that idea actually. However, very little is known about it. Sorry for asking the question here, but is there any documentation or guidance on extending extensions? I'm wondering, what's the user experience when dependencies are resolved? Will they be auto-installed?...
@reiniroosh Extending Extensions works quite well, and uses the dependency structure. Erik describes it nicely here:
https://www.hougaard.com/how-to-reference-another-extension-from-an-extension/
We even have a triple extension in one place:
- Base Library Extension
- Extension
- External Integration Extension
There are a few annoyances though:
- I was not able to get the compatabilityId to work, so I needed to always reference the exact version.
- When you make a change to a parent extension, the child extension cannot be installed on your database, even if the change does not break data structure or call structure. So when I add a new function to my Base Library, I need to uninstall/unpublish my Extension and my External Integration Extension, republish my Base Library, then republish my Extension and External Integration. During debugging, it gets tedious.
@bwdeleeuw Is correct in that creating extensions on top of extension is supported via dependencies. However, you need not follow the 'steps' defined in the linked article in your case since you should already have the extension package you want to depend on. You will need to indicate your dependency in the app.json, however, you can just place your dependency .app package directly inside of the .alpackages folder of your VSCode environment.
As to the issues pointed out
-
CompatibilityId is a hold out from extensions V1 and is 'currently' not used/respected in V2.
-
This actually sounds unexpected. @bwdeleeuw could you outline your 'steps/tools' for this, the scenario of 'non-breaking' changes to the underlying package should not require you to re-publish all of its dependencies.
@HunterFeltman-MSFT
Not a problem.
- Currently I have all three dependency-extensions published and installed on a NAV 2018 NA without any C/SIDE changes.
- I open the middle extension in VSCode, and pressed Ctrl+F5, without making changes of any kind. I get the following error in the Debug Console:
The request for path /nav/dev/apps failed with code 422. Reason: The extension was unable to be deployed due to a dependency between extensions.
I get the same error message when deploying the Base Library Extension from VSCode. The only one that can be deployed without this error is of course the highest tier, the one I referred to as the External Integration Extension.
Hope that helps
@reiniroosh sorry for hijacking your thread. Would you rather I create a new issue?
Ah, strictly VSCode F5 scenarios, then yes. That is the expected behavior.
The restriction in the platform is that you cannot 'uninstall' an extension that is being depended upon without also uninstalling those dependent extensions. This is because uninstalling means that the objects contained therein would no longer be 'available' and those dependents would not be able to function. (Like if you just removed table 18 and expect the customer card page to 'work')
You would receive a similar message if you tried to uninstall via the cmdlets or the ext mgmt page.
Similarly, you are not allowed to 'unpublish' an extension that is being depended upon if there are no 'viable' replacements (i.e. newer 'compatible' version is also published). This is where I was concerned about your steps. While you would still have to 'uninstall' things, you would not have to 'unpublish' everything if you bumped the version number on the 'new' package and then published it via cmdlets.
The VSCode F5 scenarios are a little different in that they first attempt to 'remove' any version of the extension you are trying to publish in order to provide a 'clean' environment. This means uninstall, sync 'clean, and unpublish. We do not make the assumption that it is 'ok' to uninstall or unpublish any dependent extensions and so leave it 'up to you' to resolve these issues before trying to publish again. The consequence of this is that we hit issues like you've described, which is unfortunate for now. There is future work to be done that relates to developing/testing 'upgrades' from VSCode that is related to this issue and would help in intermediate dependency development as well.
@bwdeleeuw oh, it's OK as long as I get my answer ;)
Yes, I understand how to develop an extension to an extension.
Thank you for the link. But, my question is what's the process or experience for deploying or installing a 3rd tier extension? (3. External Integration Extension in your example.) For example let's pretend level 2 is shipping extension, level 3 is Fedex integration. Someone searches for Fedex integration and see your (3rd level) app and wants to use it. Does that person have to manually resolve the dependencies? (And maybe just give up and say "nevermind...") Or, I'm hoping, will it install 2. and then recursively see it needs 1. and install that as well?
You bring up another good point about debugging... what's the experience or guidance for debugging a multi-level extension? Do you need to start debugging from the right extension?
The platform today will detect the need for dependencies to be installed and automatically ask the user if they would also like to install those dependencies. You can easily see this yourself if you publish/sync 2 extensions, one with a dependency on the other, and try to install the 'top tier' one from the Extension Mgmt page in the client. (or via cmdlet, whatever your preference).
For debugging, I 'believe' the answer is yes, you need to start from the right extension, but @StanislawStempin might know more...
@HunterFeltman-MSFT Thanks. Hopefully we will have a better approach to VSCode F5/debugging/data loss soon.
Yes you need to start debugging from the right extension and if the referenced extensions allow the ShowMyCode feature you will be able to debug through that one too.
@HunterFeltman-MSFT Is the one tableextension per extension final or you plan to change that and allow multiple tableextensions (same for pageextensions)?
Having multiple table and page extension objects within one solution, we see as the opportunity to better structure our code - where we might down the road decide to take and separate one feature of the app easily and publish as a different app, or just to keep our code modular per functional areas.
Any order of execution of these table and page extensions, as well as performance, within one app should be handled by server and should always give the same result if the code hasn't change.
The example you mentioned with Page Extension controls and with 'addafter' is something we can still control within the app no matter how many table extensions and page extension we have in that one solution (not talking about multiple apps), especially because we can code reference from one table extension to another. In a way, it's similar like order execution of EventSubscribers, which are however not limited to one EventSubscriber per Publisher, we just have to be mindful about it.
@ivandjordjevic I do not believe we have any plans to 'relax' this restriction currently. @StanislawStempin might be able to clarify if 'partial' objects are in the works somewhere down the line.
Optimizing development and debugging experience for a set of dependent apps is on our backlog and something that we would like to address sometime this year.
Partial objects are currently under consideration for a longer term backlog but we do not have concrete plans to implement it yet.
@reiniroosh Would not having 'partial' objects lead you automatically to create separate extensions instead for the winter shoes / rental customisations (even if they are dependent on / complement each other)?
What would be the decision criteria (from a technical and/or commercial point of view) to define the level of 'granularity' of your extensions? Imagine one NAV addon containing dozens of customisations in various areas (Finance, Trade, ...). Customisations might subsequently be classified per subdomain (e.g. Trade: Advanced Pricing, Extended Master Data, ...).
Creating one 'all-in' extension, one extension per area and/or subdomain or maybe even one per customisation?