Error when generating integration table for CDS entity with altpgen.exe
Describe the bug Getting "System.NullReferenceException: Object reference not set to an instance of an object." when trying to generate integrations table for CDS entity with altpgen.exe
To Reproduce
- Using altpgen.exe from C:\Users<user>.vscode\extensions\ms-dynamics-smb.al-5.0.280447\bin folder.
- Start Power Shell ISE as administrator
- Run script from folder above: .\altpgen -project:"C:\VSCode\CDSIntegration" -packagecachepath:"C:\VSCode\CDSIntegration\.alpackages" -serviceuri:"https://mycrm.crm4.dynamics.com" -entities:account -baseid:50500
Cache folder contains symbol files from BC 16.1.
Expected behavior A new AL file with a table extension of the account entity with the custom fields that were added in CDS.
Screenshots

5. Versions:
- AL Language: 5.0.280447
- Business Central: Plattform 16.0.12630.13614 + App 16.1.12629.12805
Update on this issue: Seems like I can generate files for custom entities but not for standard ones.
Hi,
Any news about this? Still hitting exception, but now it looks different. In this new example I tried to generate file for the account entity in CE. The altpgen version is from ms-dynamics-smb.al-5.0.288712. alpackages are from BC 16.3.
altpgen.exe -project 'C:\VSCode\CDSIntegration' -packagecachepath 'C:\VSCode\CDSIntegration.alpackages' -serviceuri 'https://mycrm.crm4.dynamics.com' -entities account -baseid 50500

Hello,
i have exactly the same issue, excepti using BC Version 16.3.14085.14363, everything behaves sames. I already tested it with a CDX Demo Enviroment and it's work very well, but on another targeted enviroment i get the same error, too.
My guess is that i maybe have insufficient permissions on the enviroment?
@ligoendeavor Could you solve this problem?
Hello,
Is there any update regarding this issue. I am struck, could not find any solution
@ChronosBerlin no, haven't solved this...
Hi, could you please send the metadata of your CDS table 'account'? You can get it by two calls to CRM API: environmenturl/api/data/v9.1/EntityDefinitions(LogicalName='account') and environmenturl/api/data/v9.1/EntityDefinitions(LogicalName='account')/Attributes
Seems like the problem is solved with the latest AL-language (altpgen.exe) in VS Code. I'm now for instance able to generate file for the account entity.
I'm now using the altpgen.exe from this folder: C:\Users<user>.vscode\extensions\ms-dynamics-smb.al-5.0.320540\bin
It is great to hear the bug got resolved. I'll close the issue and if you find another bug just open a new issue. Thanks for reporting it.
Hello guys, I'm sorry for reopening this thread. Do you know if it is possible to do this with standard tables? I mean, I'd like to do somthing like this:
.\altpgen -project:"C:\VSCode\CDSIntegration" -packagecachepath:"C:\VSCode\CDSIntegration.alpackages" -serviceuri:"https://mycrm.crm4.dynamics.com" -entities:serviceitems -baseid:5940
Is it possible? If it isn't... is the alternative to create a duplicate table of Service Item table (5940) and then clone every insert/modify/delete data from 5940 table to a 50100 new one?
Thank you
@deadmouse Yes, you can use the alptgen tool with standard tables too.