Archive for March, 2009
Just a quickie – it appears that Update Rollup 3 has been released for Microsoft Dynamics CRM 4.0.
This fixes about a dozen issues that are acknowledged in KB articles and more than 50 previously undocumented items too. The list of issues addressed can be found on KB961768
Another strange problem encountered and fixed today. The form onLoad code “suddenly” stopped working. I say “suddenly” because in fact this was a red herring and the problem turned out to be the result of a change. The symptoms were however unexpected.
Normally when a scripting error occurs in MSCRM, Internet Explorer will throw a script error dialog as the form loads (e.g. “There was an error with this field’s customized event.”):
Or alternatively a warning is shown at the bottom left of the Internet Explorer screen:
But on this occasion, there were no warnings. My first thought was to place a debugger statement into the code, but even after publishing this too failed to execute. I tried a simple alert() statement but this also failed. Odd.
Replacing all the code in the event handler with a simple alert() statement did work, so clearly this was a syntax problem, but very odd that it didn’t throw any error and in fact even blocked the debugger statement. If I were to delve deeper I’m sure I’d find that this is due to try…catch handling within the MSCRM ASPX pages…
Thanks due to Douglas Croxford’s JsLint for speeding the time to resolution somewhat.
A corrupted entity
I ran into a problem today with my client which frankly had me stumped. For some reason that I have yet to determine (though possibly related to a broken install of Update Rollup 2), the account entity got corrupted. We discovered this when somebody attempted to publish their changes to the account entity and ran into a “red” error dialog: “An error has occurred…please contact your system administrator”. This error was replicated if we tried to publish, delete any attributes from the entity or export the entity customizations. Not much scope for fixing the situation!
After studying the server trace logs (thanks to CrmDiagTool4 and Michael Hoehne’s Trace Log Viewer for easing this process), the situation wasn’t much clearer. The underlying error was:
Request URL: http://localhost/MyOrgName/AppWebServices/SystemCustomization.asmx Stack Trace Info: [NullReferenceException: Object reference not set to an instance of an object.] at Microsoft.Crm.ObjectModel.OrganizationUIService.LabelLoaderAllLanguages.LoadMetadataLabel(Int32 entityType, String attributeName, ExecutionContext context)
I also did a SQL Trace using SQL Profiler on the server, but this didn’t really provide anything new at all.
So, when faced with a problem I can’t resolve myself, I turned to Google for help. I managed to find KB article 947096 which seemed very near to my problem, but sadly none of the resolution steps would help me. I then tried importing a known good copy of the account entity customizations but that failed too. At this point I looked back at the Trace Log and tried to determine what was going on “under the hood” prior to the failure…
It was clear from the logs that CRM was trying to pull in LocalizedLabel information for my entity attributes and form controls, however I couldn’t quite fathom out which attribute was causing the NullReferenceException (it seems that the last statement in the logs – MetadataProcessObject.ExecuteQuery – was successfully completing its SQL command and the following statement which was failing was not logging any parameters and therefore didn’t provide me with a “smoking gun”). In fact there were many calls to both CrmDbConnection.InternalExecuteReader and MetadataProcessObject.ExecuteQuery so clearly there was an interative loop going on. I didn’t know which mechanism within the CRM server black box was selecting the list of attributes to process, so I looked further back and found that this loop was likely being “triggered” by the FormXML property on the OrganisationUI view.
At this point everything clicked into place: the problem, somehow, was with the published version of my form (some of you may have realised this long ago). This form xml was being re-evaluated (for some reason) prior to every publish, export or delete request and then failing some integrity or logical check. Re-importing a known good copy would not help, since it would need to be published to take effect. I only had one option left – to break all the rules and manually amend the database in order to correct the corrupted FormXml property…
So here’s what I did:
Took a backup of the current formXml property by running the following SQL statement within SQL Server Management Studio in the “_MSCRM” database (then right click on results tab and click “save as”…):
select organizationui0.ObjectTypeCode organizationui0.FormXml as 'formxml', from OrganizationUI as organizationui0 where (organizationui0.InProduction = 1 and (organizationui0.ObjectTypeCode = 1))
Next I found my “good” copy of the customizations file. I identified the start and end node that was required in order to match the same format as the existing formXML property (the starting tags were <form><entity…>). Next I copied this xml to a new file and removed all tabs and new lines, to give a single continuous string.
I saved this xml file onto my CRM server then went back to SQL Management Studio and ran the following SQL to import this long string directly into the SQL table:
declare @xmlText varchar(max) select @xmlText =(select * from openrowset (bulk 'c:\amendedformxml.txt',SINGLE_CLOB)x) update dbo.OrganizationUI set FormXml = @xmlText where (InProduction = 1 and (ObjectTypeCode = 1))
This effectively “forced” my old formXML into a published state and magically fixed my problems. Further, once I clicked “Publish” following these steps, the formXML was consequently re-evaluated again and the hitherto unpublished customizations become published (as expected) and therefore effectively no information had been lost by importing the older xml.
So I still don’t know what caused this issue… I’d love to know if anyone else has had a similar situation. I’m not entirely comfortable with the way I had to fix the problem either, but then sometimes your hand is forced into doing things you don’t want to do. I’ll monitor the situation and let you all know if there are any repercussions. In the meantime, the usual caveats apply – the steps above are definitely unsupported and could definitely render your CRM installation inoperable, so use the steps above at your own risk!
Edit: It seems that the issue below was limited to my client’s machine only. I’ve reinstalled Update Rollup 2 and the problem went away… The rest of this post is here for reference:
It seems that there is a small bug introduced It seems that my client has encountered an issue with Update Rollup 2 for Microsoft CRM. After installing, the form labels shown in the form designer are incorrectly reading from the published entity definitions, rather than the unpublished definitions. The result of this is that if you update a field label and click save, it appears not to have worked. If you ignore this apparent effect and publish your entity, lo! The field labels are indeed automagically updated after all.
Steps to reproduce:
- Open any entity for via Settings > Customization > Customize Entities > …
- Go to Forms and Views > Form
- Double-click any existing field and change the Label attribute then click OK
- At this point, the amend appears correctly
- Click the Save button on the form
- Note that your label amendment appears to have been backed out…(!)
- Close the form designer screen and from the entity record, click Actions > Publish
- Go back to the form designer via Forms and Views > Form
- Note that your label amendment has indeed persisted and is now also in production too
Edit: so we fixed this by removing UR2, rebooting, downloading UR2 afresh, reinstalling UR2 and rebooting again. Can’t imagine what failed – perhaps I had an early release of Update Rollup 2 with a bug – I seem to recall that it was silently reissued shortly after release.