0

我对 MS-CRM 非常陌生,我想检索联系人的所有详细信息

     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;

此处显示的数据包含显示名称,例如address_1_Cityemail_user

但是我想得到实际的名字,比如AddressEmail等等。

谢谢

4

3 回答 3

1

据我所知,您需要将其与用于该请求的实体的属性配对。以下是如何检索实体的示例:

RetrieveEntityRequest retrieveBankAccountEntityRequest = new RetrieveEntityRequest
{
 EntityFilters = EntityFilters.Entity,
 LogicalName = entityName
};
RetrieveEntityResponse retrieveEntityResponse = (RetrieveEntityResponse)_serviceProxy.Execute(retrieveBankAccountEntityRequest);
于 2015-03-30T15:04:47.690 回答
1

只是为了扩展 BlueSam 上面提到的内容。

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;
    }
}

以上代码将帮助您获取实体中每个属性的显示名称、逻辑名称和数据类型。同样,您也可以根据上述代码片段从 entityMetaData 对象中获取其他信息。

于 2015-03-31T01:46:03.280 回答
-1

您可以按照以下方式轻松完成

       using (var service =  new  OrganizationService(CrmConnection.Parse("CRMConnectionString")))
    {
var Res = service.Retrieve("sv_answer", new Guid("GUID Of Record"), new ColumnSet("ColumnName "));
    }
于 2016-10-19T11:49:57.567 回答