Wednesday, 12 June 2013

CRM utilities

Metadata document generator
https://xrmtoolbox.codeplex.com/releases/view/107901

Web-resource Manager,  lists down all the web resources which do not have dependency in system.
http://mscrmtools.blogspot.co.uk/2013/06/web-resource-manager-identify-and.html

Wednesday, 5 June 2013

xrm.page.getattribute does not support this object or method

When debugging Xrm.Page.getAttibute in console of ie debugger with breaking at a break point in console area was giving "xrm.page.getattribute does not support this object or method" error message.

Solution is to use: frames[0].Xrm.Page.getAttribute('attribute name').getValue()

http://stackoverflow.com/questions/12901795/object-doesnt-support-property-or-method-getattribute

Monday, 3 June 2013

QueryByAttribute

QueryByAttribute query = new QueryByAttribute
{
EntityName= "new_customentity",
ColumSet= new ColumnSet(new string{"new_customfield2","new_customfield3"})
};

query.Attributes.Add("new_customfield1");
query.Values.Add("value1");

EntityCollection records = crmService.ReteriveMultiple(query);

foreach(Entity record in records.Entities)
{
  
Console.WriteLine("custom field 2 " + record["new_customfield2"]);
Console.WriteLine("custom field 3 " + record["new_customfield3"]);

}


Tuesday, 28 May 2013

Associate Plugin not triggering

I have created a 1:N relation with customer to companies A plugin on assoicate is defined however when I assign company to customer plugin doesn't trigger. This plugin does trigger for any N:N relation but not for 1:N/N:1.

However when the association is defined using code it triggers plugin fine.

http://social.microsoft.com/Forums/en-US/crm/thread/9150f71c-39e3-473f-a022-ecc54ad37992

Wednesday, 3 April 2013

CRM 2011 database sql investigation

--List down the name of solutions and entity/form where this label is used.
select
FriendlyName, LocalizedLabel.* from [LocalizedLabel]
inner join Solution on LocalizedLabel.SolutionId = Solution.SolutionId where LocalizedLabelId = 'localised label id'

--Published Form Xml
select FriendlyName,SystemForm.* from SystemForm inner join Solution on SystemForm.SolutionId = Solution.SolutionId where FormId = 'formid'

--Form Xml exists in solution
select FriendlyName,SystemFormBase.* from SystemFormBase inner join Solution on SystemFormBase.SolutionId = Solution.SolutionId where FormId = 'form id'

--List down the Form Xml for the solution which matches the published formxml solution

select
FriendlyName,SystemFormBase.* from SystemFormBase inner join Solution on SystemFormBase.SolutionId = Solution.SolutionId inner join SystemForm on SystemForm.FormXml = SystemFormBase.FormXml where SystemForm.FormId = 'form id'

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