CRM Fetch XML Size Limit

by Daniel Halan 11. September 2009 23:07

Recently I was working on a dynamic Fetch XML query that was adding a lot of conditions. During a batch run the CRM Service started to crash when the xml size got around ~135kb. My first thought was that there were a size limit of the SOAP message that we'd cross, but after further testing it would become evident that fetch queries has a limit of 2097 <condition> elements. That is 2097 per <filer> element. If a query has linked entities that has 0-2097 conditions then the main entity can have a maximum of 2095 conditions.

Tags: ,


Implementing AJAX in your CRM 4 ISV

by Daniel Halan 23. December 2008 19:51

I've lately changed focus from MOSS 2007 to work with Microsoft Dynamics CRM solutions, anyhow. As Microsoft doesn't use the .NET 3.5 web extensions AJAX functionalities in CRM 4, and that is something that you may like to use in your ISV solutions, you need to change the "C:\Program Files\Microsoft Dynamics CRM\CRMWeb\web.config" to include all the references to the .NET 3.5 libraries. As you may know changing the web.config is not a supported customization, as after an upgrade your changes won't be there. So I have a plan of writing a small consoleapp that will add the changes to the web.config but until then here is a web.config with them included.

web.config for Microsoft CRM v4.0.7333.145 with AJAX enabled
web.config (3,35 KB)

Tags: ,


How to create a new Form from Template in a Form Library, programmatically.

by Daniel Halan 31. July 2007 03:38

Creating new files in a Document Library is a pretty simple task as copying the template located in the "Forms" folder. But creating a new Form is a bit harder as the template is a binary file, and what we want is a new Xml file.

The template file (with extension XSN) created by InfoPath is actually a CAB archive, that contains your form logic compiled, schemas and your xml template. So what you have to do is extract the CAB file, and copy the "template.xml" file to your Form Library. You can find a CAB extractor at The Code Project.

Here is a example of a method to get the template Xml:

private byte[] GetXmlForm(SPDocumentLibrary list) {
  byte[] data = null;
  SPFile file = list.ParentWeb.GetFile(list.DocumentTemplateUrl);
  Extract cab = new Extract();
  string szFolder = string.Concat(System.IO.Path.GetTempPath(), list.Title, "\\");

  if( !Directory.Exists(szFolder) )

  cab.ExtractStream(file.OpenBinaryStream(), szFolder);
  FileStream fs = new FileStream(szFolder + "template.xml", FileMode.Open);
  try {
    data = new byte[fs.Length];
    fs.Read(data, 0, data.Length);
  } finally {
  return data;

There is one more thing that has to be done before saving the template, which is to add a hyperlink to your InfoPath Template. The href should be added in the processing instruction tag "mso-infoPathSolution" ie.
<?mso-infoPathSolution href="http://server/site/library/Forms/myTemplate.xsn" ?>

Here is a snippet on how to do it:


void SetTemplateUrl(string url) {
  foreach(XmlNode n in m_Doc.ChildNodes) {
    if(n.Name == "mso-infoPathSolution") {
      string szHref = string.Format("href=\"{0}\"", url);
      Regex r = new Regex("href=\".*\"");
        n.Value = r.Replace(n.Value, szHref);
      else n.Value = string.Concat(n.Value,szHref,' ');


How to get the .NET Assembly full name

by Daniel Halan 23. March 2007 00:48

There is often that one need to get an assembly’s full name, while one can do it quite simply in C# by instancing the assembly and calling GetName(), but when setting up applications outside the development environment, You can use SN.exe to retrieve the PublicKeyToken using the -T parameter, but still it would be nice to get the whole Assembly Name, so here is a small command prompt app that does the job.

Example of an Assembly full name:
"GetAsmName, Version=, Culture=neutral,

Copy the files to Windows\System32 folder or add the path to your PATH environment variable.

GetAsmName <<path\fileName.dll|exe>>

Download the compiled application:

.NET Version 2.0 (2,83 KB)

.NET Version 4.0 (3.22 kb)


Source Code available at GitHub

Blog3ngine dot NET
Theme by Daniel Halan

About the author

Daniel Halan Daniel Halan, M.Sc., Microsoft Windows Azure Advisor Software Architect and Lead Developer from Sweden, currently in Bangkok.

Working primary with Microsoft .NET, Windows Azure, DDD, CQRS and some Dynamics CRM  Read more...

The content of this site are my own personal opinions and do not represent my employer's view in anyway.

My Favourite Websites

Month List