Announcements
I am trying to install an extension locally with the PS commands publish-navapp and install-navapp and get the error "You must select a company before you can access the item table". I am simply trying to add some items in a subtype=install codeunit. Has anyone else experienced this error? I have searched for an answer and cannot find one.
Thanks.
The error you are receiving usually suggests that you are attempting to access a table whose data is considered ‘Per-Company’ outside of a company context.
The default value for all tables in the AL syntax is for the data to be ‘Per-Company’ but can be set explicitly with the ‘DataPerCompany’ property.
Code similar to this:
table 50100 MyPerDatabaseTable
{
DataPerCompany = false; // Makes the table per-database
// <Table fields, code, etc.>
}
From your description, I might assume that the problematic code is being executed from within the ‘OnInstallAppPerDatabase’ trigger in your install codeunit. When this trigger is run there is no company context, so any attempt to access a per-company table from there would result in this error.
If you need to perform ‘install’ related tasks for you per-company tables, then they should be done in the ‘OnInstallAppPerCompany’ trigger instead.
See this reading:
https://docs.microsoft.com/en-us/dynamics-nav/developer/devenv-extension-install-code
André Arnaud de Cal...
294,217
Super User 2025 Season 1
Martin Dráb
232,978
Most Valuable Professional
nmaenpaa
101,158
Moderator