Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

CRM 2013, C# PlugIn - FetchXML

$
0
0

Hi 

I have the following code that is getting data from my grid and exporting to a CSV file;

string fetchxml = @"<fetch mapping= 'logical'><entity name ='product'><attribute name = 'name'/></entity></fetch> ";
EntityCollection result = service.RetrieveMultiple(new FetchExpression(fetchxml));foreach(var c in result.Entities)
  {
     if (result != null && result.Entities.Count > 0)
       {
         List<string> _product = new List<string>();
         foreach (Entity _entity in result.Entities)
           {
             _product.Add(_entity.Attributes["name"].ToString());
           }
string CSVFile = string.Join(",", _product.ToArray());
string AddressPath = "FM-OR" + "_";
string AddressSavePath = @"\\fm\CRMdata\maesteg\" + AddressPath + ".csv";

System.IO.File.WriteAllText(AddressSavePath, CSVFile.ToString());
}
}


My problem is that my fetchXML is returning all the items in product not just the selected ones in the grid, does anyone know how to stop this? 

Thanks, Shaun


S.Harrison


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>