Recently I had a weird experience with Dynamics 365 (running on Update 2.0) when the entire Dynamics 365 organization went down when I attempted to create a Currency field. Since I haven’t seen come across any article or post where someone faced this, I decided to post how this was solved (kind of) so others might benefit from it.
How we encountered this issue?
So, this is what happened. We moved the the customization from our development to staging environment, using an unmanaged solution. The Staging environment was a Vanilla organization and this was our first deployment in this environment. We were running Version 1612 (8.2.0.749) On-Premise. Right after we moved the solution, a few of our reports stopped working and on investigating we found the “Exchange Rate” field was missing from one of our custom entities. Now, this is an OOTB (out of the box) field that’s created by CRM for the entity when you have any Currency field. The solution had it and so did the Development environment, so there was no reason as to why it wouldn’t move to the Staging. I happened to check both the Default solution and the Database table of Staging and it was missing as expected. So a crazy idea dawned on me, and I thought what if I create a Currency field CRM might create that field. And so I went ahead and the moment I hit “OK” after entering a currency field name, Dynamics 365 went down! Yikes!!! Everyone trying to access the organization, got a “404 – File or Directory Not Found”.
Now mind it, the other Staging organizations (we have multiple Staging Organizations) worked just fine, confirming there was something messed up with the metadata of the Organization we were working on.
Internal Troubleshooting. Logs anyone?
After enabling advanced trace logging, we found something to do with the “Money Attribute Calculation” but we were not sure what was happening in the back end. The exact name of the method that was throwing the exception was “Microsoft.Crm.Metadata.PreloadedAttributeMetadataDataProvider.InitializeMoneyAttributeCalculation”.
Mind it, to make sure the entire trace of error is logged you need to add 6 registry keys in the CRM Server(s).
Registry Key | Type | Value |
---|---|---|
TraceEnabled | DWORD | 1 |
TraceRefresh | DWORD | 1 |
TraceDirectory | String | C:\Program Files\Microsoft Dynamics CRM\Trace |
TraceCategories | String | *:Verbose |
TraceCallStack | DWORD | 1 |
The trace logs gave us this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# CRM Tracing Version 2.0 # LocalTime: 2017-06-29 00:00:46.345 # Categories: # CallStackOn: No # ComputerName: MYSERVERNAME1 # CRMVersion: 8.2.0.749 # DeploymentType: OnPremise # ScaleGroup: # ServerRole: AsyncService, DeploymentService, SandboxServer, DeploymentManagementTools, VssWriter, EmailConnector [2017-06-29 00:00:46.345] Process:CrmAsyncService |Organization:5f8e2095-dc13-463e-8dee-56f1906b860b |Thread: 50 |Category: Platform.Async |User: 00000000-0000-0000-0000-000000000000 |Level: Error |ReqId: 00000000-0000-0000-0000-000000000000 |ActivityId: a3229b66-2576-41d7-bcbb-25ed8d42066d | AsyncEventHandlerCommand`1.Execute ilOffset = 0xD7 >Exception while trying to execute AsyncOperationId: {EC1C1A9C-E91A-4A7C-B1F3-6D7E2872CFA0} AsyncOperationType: 40 - System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Crm.Metadata.PreloadedAttributeMetadataDataProvider.InitializeMoneyAttributeCalculation(MoneyAttributeMetadata attribute, IPreloadedMetadataInitializationContext context) at Microsoft.Crm.Metadata.PreloadedAttributeMetadataDataProvider.Initialize(IPreloadedMetadataInitializationContext context, IMetadataCacheDataProvider metadata, LoadMasks masks) at Microsoft.Crm.Metadata.PreloadedMetadataCacheDataProvider.InitializeAttributes(IPreloadedMetadataInitializationContext context, LoadMasks masks) at Microsoft.Crm.Metadata.PreloadedMetadataCacheDataProvider.Initialize(IOrganizationContext organizationContext, MetadataContainer container, LoadMasks masks) at Microsoft.Crm.Metadata.MultiOrgSharableMetadataCacheLoader.CreateMetadataCacheDataProvider(MetadataContainer container, LoadMasks masks, CounterList counter) at Microsoft.Crm.Metadata.DynamicMetadataCacheLoader.BuildMetadataCacheFromMetadataContainer(MetadataContainer container, LoadMasks masks, CounterList counter) at Microsoft.Crm.Metadata.DynamicMetadataCacheLoader.LoadCacheFromDatabaseInternal(LoadMasks masks, CrmDbConnection connection, CrmTransaction transaction, CounterList counter) at Microsoft.Crm.Metadata.DynamicMetadataCacheLoader.LoadCacheFromDatabase(LoadMasks masks, CounterList counter) at Microsoft.Crm.Metadata.DynamicMetadataCacheFactory.LoadMetadataCache(LoadMethod method, CacheType type, IOrganizationContext context) at Microsoft.Crm.Metadata.MetadataCache.LoadCache(IOrganizationContext context, Boolean fileOnlyIfExists) at Microsoft.Crm.Metadata.MetadataCache.GetInstance(IOrganizationContext context) at Microsoft.Crm.BusinessEntities.BusinessEntityMoniker..ctor(Guid id, String entityName, IOrganizationContext orgContext) at Microsoft.Crm.Caching.OrganizationSettingsCacheLoader.LoadCacheData(Guid key, ExecutionContext context) at Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key, IOrganizationContext context) at Microsoft.Crm.Caching.CrmMultiOrgCacheBase`2.CreateEntry(TKey key, IOrganizationContext context) at Microsoft.Crm.Caching.CrmMultiOrgCacheBase`2.LookupEntry(TKey key, IOrganizationContext context) at Microsoft.Crm.ObjectModel.GoalManagement.RollupEngineFactory.RollupConfiguration..ctor(Guid organizationId, RollupEngineType rollupType) at Microsoft.Crm.ObjectModel.GoalManagement.RollupEngineFactory.CreateRollupEngine(ICrmDataAccess crmDataAccessObject, IRollupTreeProvider rollupTreeInfoFactory, RollupEngineType type, Guid organizationId) at Microsoft.Crm.Asynchronous.GoalRollupOperation.InternalExecute(AsyncEvent asyncEvent) at Microsoft.Crm.Asynchronous.AsyncEventHandlerCommand`1.Execute(IAsyncEvent asyncEvent) |
What we did to fix (sort of) the issue?
Being unable to do anything to fix it, we resorted to the highest level of Microsoft support. The Support personnel got back to us after analyzing the logs saying that it was a known issue in Version 8.1 (which is Dynamics 2016) but we were using Version 8.2 (Dynamics 365). She said that meant the issue somehow bubbled up to Dynamics 365 and would be fixed in the next major update (not 8.2.1 that was released in May 2017). She gave us a query that made the organization open up fine, but the “Exchange Rate” field was still missing.
This was the SQL Query we ran against the Organization database:
1 2 3 |
UPDATE attribute SET IsBaseCurrency = NULL WHERE attributeid in (select attributeid from attribute where IsBaseCurrency is not null and entityid not in (select entityid from attribute where name = 'exchangerate')) |
It updated two records:
Although now we can access the Organization, our reports are still broken and we are contemplating whether or not to rollback the database and figure out the actual cause for the missing field and how we can “inject” it from the back end to actually fix the issue.
But if you have faced this issue and none of your fields are missing, it might help you get your Organization back!
Hope this helps! Until next time!
Have something to add?
Be First to Comment
No Trackbacks.