0

I am very new to MS-CRM and I want to retreive all the details of the contact

     var executeQuickFindRequest = new OrganizationRequest("ExecuteQuickFind");
            executeQuickFindRequest.Parameters = new ParameterCollection();


            var entities = new List<string> { "contact", "lead", "account" };                //specify search term                
            executeQuickFindRequest.Parameters.Add("SearchText", "maria");
            //will cause serialisation exception if we don't convert to array                
            executeQuickFindRequest.Parameters.Add("EntityNames", entities.ToArray());

            var executeQuickFindResponse = _orgService.Execute(executeQuickFindRequest);
            var result = executeQuickFindResponse.Results;

The data here displayed contains display name's such as address_1_City,email_user

However I want to get there actual names like Address,Email etc etc.

Thanks

Rohit
  • 10,056
  • 7
  • 50
  • 82

3 Answers3

1

As far as I know, you will need to pair it up with the attributes of the entities that are for that request. Here's a sample of how to retrieve an entity:

RetrieveEntityRequest retrieveBankAccountEntityRequest = new RetrieveEntityRequest
{
 EntityFilters = EntityFilters.Entity,
 LogicalName = entityName
};
RetrieveEntityResponse retrieveEntityResponse = (RetrieveEntityResponse)_serviceProxy.Execute(retrieveBankAccountEntityRequest);
BlueSam
  • 1,888
  • 10
  • 17
1

Just to extend what BlueSam has mentioned above.

EntityMetadata entityMetaData = retrieveEntityResponse.EntityMetadata;
for (int count = 0; count < entityMetaData.Attributes.ToList().Count; count++)
{
    if (entityMetaData.Attributes.ToList()[count].DisplayName.LocalizedLabels.Count > 0)
    {
        string displayName = entityMetaData.Attributes.ToList()[count].DisplayName.LocalizedLabels[0].Label;
        string logicalName = entityMetaData.Attributes.ToList()[count].LogicalName;
        AttributeTypeCode dataType = (AttributeTypeCode)entityMetaData.Attributes.ToList()[count].AttributeType;
    }
}

Above code will help you to get the display name, logical name and data type for each attribute in the entity. Similarly you can get other information as well from the entityMetaData object as per above code snippet.

Renjith
  • 755
  • 4
  • 7
-1

You can do it easy as below

       using (var service =  new  OrganizationService(CrmConnection.Parse("CRMConnectionString")))
    {
var Res = service.Retrieve("sv_answer", new Guid("GUID Of Record"), new ColumnSet("ColumnName "));
    }