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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,186 Super User 2024 Season 2
Martin Dráb 227,996 Super User 2024 Season 2
nmaenpaa 101,148