I am trying to create a test company using Powershell and the following steps with NAV 2013r2 Update 11.
1. Export-NAVData (I've tried both UseNST_SomeCompanies, and UseDatabase_SomeCompanies)
2. Rename-NAVCompany
3. Import-NAVData
The Export and Rename complete without error. The Import fails with the following message:
========================================================================================
Import-NAVData -databaseName NAV2013_GoLive -FileName C:\install\NAV2013_GoLive.navdata -ApplicationDatabaseName NAV2013_GoLive -ApplicationDatabaseServer DBSERVER2 -CompanyName "PHBTest" -DatabaseServer DBSERVER2 -Force
WARNING: UnhandledErrorMessage
Import-NAVData : Object reference not set to an instance of an object.
At line:1 char:1
+ Import-NAVData -databaseName NAV2013_GoLive -FileName C:\install\NAV2013_GoLive. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-NAVData], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.Dynamics.Nav.Management.Cmdlets.ImportNavData
========================================================================================
I have:
1. Recompiled all of the objects, retried export/import.
2. Performed a Sync-NAVTenant
3. Tried it with and without application/applicationdata/globaldata
4. Tried doing it through the user interface - with the same result.\
5. Performed the following query per Gunnar ...
Delete from [<<Source Database>>].[dbo].[Object Metadata Snapshot] Where [Object ID] IN
(2000000007, 2000000026, 2000000049, 2000000101, 2000000102, 2000000103, 2000000020, 2000000055, 2000000009, 2000000029, 2000000038, 2000000058, 2000000041, 2000000028, 2000000063, 2000000022, 2000000048, 2000000040, 2000000043, 2000000044, 2000000039, 2000000045)
I have no idea why the schema would be different, or if that is what is causing the error. I'm stumped.
Our workaround is a test SQL dB and service tier to service it. Not nearly as elegant as just changing companies.
Update on this .... I was just successful using the COPY Action on the Companies list via the RTC client. Absolutely whacky. I'd still like to do this with powershell if I can get past the error.
Please help!
Mark Tyler
Pacific City, OR
0
Comments
Are Export and Import database same or different ?
Microsoft Dynamics NAV Consultant
Jatin's Blog
Just curious, why do you not use the Copy-NAVCompany cmdlet? [ I do not know if that is already available in your build - that might explain.... ]
I didn't use the Copy-Company Cmdlet because of ignorance. And now I'll just have the user go to the companies page and use the Copy Company Action posted there... :oops: - this is a big "duh" moment, but that's how we learn.
That sidesteps the whole issue of how we as an ISV might be able to use Export-NAVData and Import-NAVData to take our demo/training company and drop it into an upgraded customer's database. I'd love to figure out why Import is throwing errors when the navdata file being imported was JUST EXPORTED from the same database after performing all of the incantations that are supposed to make it work.
Thanks for the responses!
Pacific City, OR