{Advanced XRM DEVELOPMENT}Retrieve entity image url for crm 2013/2015

Sometimes we get requirement to find the url of image field on record. Considering example of contacts , here is the example to retrieve the URL below:

QueryByAttribute query = new QueryByAttribute(“contact”);

query.ColumnSet = new ColumnSet(“entityimage_url”);

query.Attributes.AddRange(“lastname”);

query.Values.AddRange(“sample”);

EntityCollection binaryImageResults = _service.RetrieveMultiple(query);

foreach (var record in binaryImageResults.Entities)

{

     String recordName = record.Attributes[“entityimage_url”].ToString();

     Console.WriteLine(recordName);

}

Hope it helps!

Advertisement