I have a Grid on my entity page Orders, users can add products to the entity grid
For my plugin I need to know what products have been inserted into the grid so that I can then produce a CSV file
I've tried using a FetchXML query to retrieve the data which is as follows;
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());
}
}
The code does produce the required CSV file that I need however it's selected every record in the entity products instead of the required ones in the grid. Any suggestions on how I sort this problem?
Thanks, Shaun