This is a draft post that I never finished, still the information is quite useful so I hope it helps someone. Read it as "a couple of months ago" :) //Rickard
It's been a while since I published something here, seems as the days are too short. Today I will discuss two problems I've encountered in the past weeks which gave me some (more) gray hair.
First thing happened this morning when a customer called saying that she couldn't run a report on an advanced find she had been using earlier. I tried to use the report on a small number of objects, 10 or so, on ALL objects and using the advanced find to select many objects (roughly 1700). I had no problems but when the customer did the same thing she got the following results: On a few objects the report worked as intended, on 250 objects it worked, on all objects it worked but when chosing all objects on all pages of the selected view after using the advanced find the report viewer just showed "error on page" at the bottom of the window. When closing the window I got prompted if I wanted to send info to Microsoft which I viewed and it said that "the object doesn't support the property or method".
Considering that I could use the report I set the system administrator role for the customer and when she tried again the report worked. A security issue one would think, well I removed the system administrator role to start test different possible scenarios but gave it a go again and tested the report. To my surprise it worked, the only thing I did was to assign the sysadmin role to the user, run the report and then remove it again. Very strange.
The other problem I had a few weeks ago when I was modifying existing, and working, code with a new function. Things went south pretty fast and I had to acquaint myself with the wonderful world of error messages in CRM 2011. What I did was that I needed to move variables from the pre operation state to the post operation state of a plugin. With these variables I would do an update and it had to be done after the operation.
Right, I consulted the all knowing SDK, The Junior Woodchuck Guidebook of Dynamics CRM. The answer was actually quite simple, SharedVariables. So since I wanted to pass a few variables I had a look at the structure which was a key-value pair so I figured I could pass an XML-object, which I did.
That was not the correct thing to do. There were no error messages when I did it but boy did things blow up when I used the plugin. It seems that you can't put anything serializable in the shared variables so I had to somehow enumerate the data that I put into the shared variables and then go through the set in the post state code, which worked quite alright actually. Lessen learned, don't put serializable objects in the shared variables, even if an XML might seem like something else.
In hindsight, I wonder if it might have worked with an XML as a string field which you read into an XML in the post state code.
Developer at CRM-Konsulterna