【发布时间】:2018-01-10 06:20:46
【问题描述】:
我在潜在客户实体上有帐户和联系人查找字段。我想获取联系人的帐户名称和电子邮件地址。
我收到无效参数错误。
代码:
public EntityCollection GetDetails()
{
string fetchXML = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='lead'>
<attribute name='fullname' />
<attribute name='leadid' />
<attribute name='new_contact'/>
<attribute name='new_account'/>
<order attribute='fullname' descending='false' />
<filter type='and'>
<condition attribute='leadqualitycode' operator='eq' value='1' />
</filter>
</entity>
</fetch>";
EntityCollection records = service.RetrieveMultiple(new FetchExpression(fetchXML));
return records;
}
public string GetAccountDetail(EntityCollection records)
{
if (records.Entities.Count != 0)
{
accountid = records.Entities[0].GetAttributeValue<Guid>("new_account");
tracingService.Trace("AccountId :" + accountid);
Entity accountDetails = service.Retrieve("account", accountid, new ColumnSet("name"));
string accountname = accountDetails.Attributes["name"].ToString();
tracingService.Trace("AccountName :" + accountname);
return accountname;
}
return name;
}
【问题讨论】:
-
Service.Retrieve
-
我只使用它,但我收到了 Invalid Argument 错误。
-
您确定这些字段名称正确吗?查找字段通常为
xxx_lookupid格式。 -
@JamesWood 字段名称正确。
-
我在 accountid 行上收到此错误:发生“System.InvalidCastException”类型的异常
标签: c# plugins dynamics-crm microsoft-dynamics dynamics-crm-online