James Downey’s CRM Blog
Thoughts on the technology and business of CRM

Pulling Attribute Values into Variables from FetchXML Result

Friday, 26 June 2009 06:39 by James Downey

Over the years, I've recieved several emails from users of FetchXML Builder about how to pull the data retreived by CrmService Fetch method into variables. When you use FetchXML Builder, you will see rather quickly that the results are returned as XML so it makes sense to use the XmlDocument class to manipulate this data. So start by placing a "using System.Xml;" clause at the top of your C# file and modify the code below to fit your needs.

string result = service.Fetch(fetchXML);
string attributevalue;

XmlDocument doc = new XmlDocument();
doc.LoadXml(result);

foreach(XmlNode node in doc.DocumentElement.ChildNodes)
{
     attributevalue = node.SelectSingleNode("mycrmattribute").InnerText;
}

Currently rated 5.0 by 5 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   FetchXML
Actions:   E-mail | del.icio.us | Permalink | Comments (686) | Comment RSSRSS comment feed

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading