Wednesday, 13 March 2013

systemuser with Id = guid Does Not Exist

I have created a crm org in one server, then imported that org from that server to dev server and then imported few solutions on top it.

things were fine however in order to diagnose one of the bug client was facing I deployed solution to debug as I used to do in my old dev machine/domain.

When solution was deployed some of the plugins were working fine however on couple of plugins I was getting following error

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: systemuser With Id = 56702f79-c33a-e111-8820-00155d450361 Does Not ExistDetail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
  <ErrorCode>-2147220969</ErrorCode>
  <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
  <Message>systemuser With Id &amp;#61; 000000000-0000-0000-0000-000000000000 Does Not Exist</Message>
  <Timestamp>2013-03-13T10:05:18.7976683Z</Timestamp>
  <InnerFault i:nil="true" />
  <TraceText>
[Plugins:Plugins.PluginName]
[000000000-0000-0000-0000-000000000000: PluginName]
Entered Plugins.PluginName.Execute(), Correlation Id: 000000000-0000-0000-0000-000000000000, Initiating User: 000000000-0000-0000-0000-000000000000 Plugins.PluginName is firing for Entity: prefix_entityname, Message: Update, Correlation Id: 000000000-0000-0000-0000-000000000000, Initiating User: 000000000-0000-0000-0000-000000000000 Exception: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: systemuser With Id = 000000000-0000-0000-0000-000000000000 Does Not Exist (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault)., Correlation Id: 000000000-0000-0000-0000-000000000000, Initiating User: 000000000-0000-0000-0000-000000000000
Exiting Plugins.PluginName.Execute(), Correlation Id: 000000000-0000-0000-0000-000000000000, Initiating User: 000000000-0000-0000-0000-000000000000
</TraceText>
</OrganizationServiceFault>

when trying to find something from plugin registeration tool, nothing was strange, plugins are running under calling user.

REASON/Resolution: This was happing due to I am using crm development toolkit, and in RegisterFile.crmregister I am using ImpersinatingUser to run plugin under certain useraccount. and here it had old crm user GUID which was valid in different domain and crm org but for my current new crm orgs under new domain are invalid.

Tuesday, 12 March 2013

SQL Profiling

I was investigating a bug on UAT environment which was one-off and apparently not reproduce able in  other environments. After spending many hours I didn't know what was causing the issue due to lack of logging and error message in event viewer. I was left with 2 options first to enable tracing on CRM server and second was to go to SQL profiling which is not a preferred option generally. However due to number of front end servers running, turning on tracing on each of them was not my preferred option in this case and I opted for SQL profiling.  I was generating SQL tracing information for the action which was giving error, and I made sure we do SQL profiling after business hours.

Before starting the profiling stop any service which can trigger lots of SQL tracing. In my case i was investigating some ui issue so I disabled Microsoft Async Service and Reporting Service for some time.
Following are the steps to do sql profiling.

Open SQL server Management studio, then go to "Tools" -> "SQL Server Profiler" option.

On Trace properties prompt shown select "Event Selection" tab.
Select "Show all events" check-box.

Expand security option and select
- Audit Login
-Audit Logout

Expand Stored Procedures option and select
-RPC output parameter
-RPC:Completed
-RPC:Starting
-SP:Completed
-SP:Starting
-SP:StmtCompleted
-SP:StmtStarting

Expand TSQL
-SQL:BatchCompleted
-SQL:BatchStarting