Convert SQL query to Microsoft Dynamics CRM FetchXML

Found interesting Online Tool to convert SQL query to Microsoft Dynamics CRM FetchXML. Click here to have a look.

SQL2FetchXML

Advertisements

Generate Early bound Class using CrmSvcUtil.Exe in CRM

CrmSvcUtil.exe is a command-line code generation tool for use with Microsoft Dynamics CRM. This tool generates Early bound class in C# with Custom entities and attributes. Provides Intellisense Support.

Follow the below steps to create early bound class,

Step 1: Download Latest CRM SDK.

Step 2: Open Run and type cmd.

Step 3: In SDK\bin, we can see crmsvcutil.exe. Now provide the path “CRM\SDK\bin” in command prompt.

Example: I have downloaded the CRM SDK on my desktop. So, path in command prompt will be like below,

Crmsvcutil - CMD

Step 4: Now we have to execute crmsvcutil.exe from command prompt with the following command,

CrmSvcUtil.exe
/url:<Organization Service>
out:<Class Name>.cs
/username:"<User Id>"
/password:"<Password>"
/namespace:<Namespace>
/serviceContextName:<Context Name>
Parameter Description
Organization Service Provide Organization Service. Goto Microsoft Dynamics CRM ->Settings -> Customizations -> Organization Service.
Class Name Provide Output Class Name. Ex: D:\OutputFile.cs
User Id Provide Online 365 User Id or On-Premise domain\userid .
Password Provide Password.
Namespace Provide Namespace name.
Context Name Provide Context Name.

Example:

CrmSvcUtil.exe /url:https://OrgName.api.crm5.dynamics.com/XRMServices/2011/Organization.svc /out:C:\Users\arunpotti\Desktop\EarlyBound.cs /username:"arunpotti@OrgName.onmicrosoft.com" /password:"password" /namespace:earlybound /serviceContextName:ServiceContext

Step 5: Paste the command line in command prompt and click on enter to generate class file.

Crmsvcutil - CMD line

Please provide your valuable comments on this article.

FetchXML Formatter Tool

It is a Light weight windows application and this tool will be helpful when you are extensively working with FetchXML in Javascript / C# code to get desired result.

Functionality:

It will take FetchXML from Advance Find as an input and convert that into desired format, which can be used into Javascript / C# for further coding.

Pros:

  1. No Need to spend time for FetchXML formatting
  2. It is easy to use.
  3. Works for both Javascript and C# code

Example:

Let us take a simple example of the below FetchXML,

 <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="contact">
    <attribute name="fullname" />
    <attribute name="telephone1" />
    <attribute name="emailaddress1" />
    <attribute name="contactid" />
    <order attribute="fullname" descending="false" />
    <filter type="and">
      <condition attribute="ownerid" operator="eq-userid" />
      <condition attribute="statecode" operator="eq" value="0" />
    </filter>
  </entity>
</fetch>

Provide this as an input to FetchXML formatter Tool, 1. Check Javascript radio button and click on Format to see the below output,

"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
"  <entity name='contact'>"+
"    <attribute name='fullname' />"+
"    <attribute name='telephone1' />"+
"    <attribute name='emailaddress1' />"+
"    <attribute name='contactid' />"+
"    <order attribute='fullname' descending='false' />"+
"    <filter type='and'>"+
"      <condition attribute='ownerid' operator='eq-userid' />"+
"      <condition attribute='statecode' operator='eq' value='0' />"+
"    </filter>"+
"  </entity>"+
"</fetch>"

2. Check C# radio button and click on Format to see the below output,

@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
  <entity name='contact'>
    <attribute name='fullname' />
    <attribute name='telephone1' />
    <attribute name='emailaddress1' />
    <attribute name='contactid' />
    <order attribute='fullname' descending='false' />
    <filter type='and'>
      <condition attribute='ownerid' operator='eq-userid' />
      <condition attribute='statecode' operator='eq' value='0' />
    </filter>
  </entity>
</fetch>"

Click Here to download the FetchXML Formatter Tool Exe file

Screen Shots:

FetchXMLFormatter - Pic 1
FetchXMLFormatter - Pic 2
FetchXMLFormatter - Pic 3
FetchXMLFormatter - Pic 4
Please provide your valuable feedback on this article.