Convert fetchXML to SQL Query in MSCRM 4.0
If for some sane reasons if fetchxml needs to be converted to a SQL Query in MSCRM 4.0, it is possible.
It actually requires the below DLL's which are avilable in the folder Server\setup
Microsoft.Crm.dll, Microsoft.Crm.Platform.Server.dll and Microsoft.Crm.Reporting.dll
The code looks as below :
Microsoft.Crm.BusinessEntities.ExecutionContext myContext = new Microsoft.Crm.BusinessEntities. ExecutionContext (OrganizationId from the context);
myContext.OnBeginRequest(UserId, false);
Microsoft.Crm.Reporting.ReportQueryBuilder myreportQueryBuilderObj = new ReportQueryBuilder();
string Query = myreportQueryBuilderObj.BuildReportQuery(fetchXml, myContext);
The query will be returned as string. The Query is not readable but it works, -:)
It actually requires the below DLL's which are avilable in the folder Server\setup
Microsoft.Crm.dll, Microsoft.Crm.Platform.Server.dll and Microsoft.Crm.Reporting.dll
The code looks as below :
Microsoft.Crm.BusinessEntities.ExecutionContext myContext = new Microsoft.Crm.BusinessEntities. ExecutionContext (OrganizationId from the context);
myContext.OnBeginRequest(UserId, false);
Microsoft.Crm.Reporting.ReportQueryBuilder myreportQueryBuilderObj = new ReportQueryBuilder();
string Query = myreportQueryBuilderObj.BuildReportQuery(fetchXml, myContext);
The query will be returned as string. The Query is not readable but it works, -:)
And how can i create execution context?
ReplyDeleteCan you provide full code?
Thanks in advance!
I try it, but i got an exception. do you have the full code.
ReplyDeleteThanks in advance
Hi ,
ReplyDeleteI made this tool might it help you.
mail me if you need this.. it free !!
sbhagat@yamaha-motor-india.com
Hi!
ReplyDeleteWhen i use in link-entity condition lookup BuildReportQuery return null. Any ides?