Dynamics CRM 2016 以编程方式创建和鉴定潜在客户 C#
Dynamics CRM 2016 Create and Qualify a Lead Programmatically C#
我正在尝试以编程方式创建一个主要实体,我了解到在 dynamics crm 2016 中不再有针对特殊字段的特殊消息。
因此,我从动态 crm 服务器检索数据并将其插入另一个 crm 服务器,没有使用如下所示的特殊消息:
account["statecode"] = new OptionSetValue(1); //inactive
account["statuscode"] = new OptionSetValue(2); //inactive
问题是 statecode
中的值为“1”的潜在客户记录,这意味着是合格的潜在客户,而 statuscode
的值为“3”,这意味着也是合格的.
无论如何,当我尝试插入时出现以下消息引发的错误:
3 is not a valid status code for state code LeadState.Open
仅供参考,LeadState.Open
的值为“0”,即使我之前提到的领先状态是“1”。
我不知道到底是什么问题。
您应该按照 SDK 中的说明使用 QualifyLeadRequest
。与 SetState
不同,此消息未被标记为弃用。合格潜在客户工作流程比设置状态流程更复杂,因为它包括(可选)创建和链接到客户、联系人和机会记录。
这是 SDK 中的一个示例,该示例使用现有的 account
.
来限定潜在客户以创建 opportunity
// Qualify the second lead, creating an opportunity from it, and not
// creating an account or a contact. We use an existing account for the
// opportunity customer instead.
var qualifyIntoOpportunityReq = new QualifyLeadRequest
{
CreateOpportunity = true,
OpportunityCurrencyId = currencyId,
OpportunityCustomerId = new EntityReference(
Account.EntityLogicalName,
_accountId),
Status = new OptionSetValue((int)lead_statuscode.Qualified),
LeadId = new EntityReference(Lead.EntityLogicalName, _lead2Id)
};
var qualifyIntoOpportunityRes =
(QualifyLeadResponse)_serviceProxy.Execute(qualifyIntoOpportunityReq);
Console.WriteLine(" The second lead was qualified.");
foreach (var entity in qualifyIntoOpportunityRes.CreatedEntities)
{
NotifyEntityCreated(entity.LogicalName, entity.Id);
if (entity.LogicalName == Opportunity.EntityLogicalName)
{
_opportunityId = entity.Id;
}
}
从中获取此代码的示例具有更多详细信息:https://msdn.microsoft.com/en-us/library/hh547458.aspx。
我正在尝试以编程方式创建一个主要实体,我了解到在 dynamics crm 2016 中不再有针对特殊字段的特殊消息。
因此,我从动态 crm 服务器检索数据并将其插入另一个 crm 服务器,没有使用如下所示的特殊消息:
account["statecode"] = new OptionSetValue(1); //inactive
account["statuscode"] = new OptionSetValue(2); //inactive
问题是 statecode
中的值为“1”的潜在客户记录,这意味着是合格的潜在客户,而 statuscode
的值为“3”,这意味着也是合格的.
无论如何,当我尝试插入时出现以下消息引发的错误:
3 is not a valid status code for state code LeadState.Open
仅供参考,LeadState.Open
的值为“0”,即使我之前提到的领先状态是“1”。
我不知道到底是什么问题。
您应该按照 SDK 中的说明使用 QualifyLeadRequest
。与 SetState
不同,此消息未被标记为弃用。合格潜在客户工作流程比设置状态流程更复杂,因为它包括(可选)创建和链接到客户、联系人和机会记录。
这是 SDK 中的一个示例,该示例使用现有的 account
.
opportunity
// Qualify the second lead, creating an opportunity from it, and not
// creating an account or a contact. We use an existing account for the
// opportunity customer instead.
var qualifyIntoOpportunityReq = new QualifyLeadRequest
{
CreateOpportunity = true,
OpportunityCurrencyId = currencyId,
OpportunityCustomerId = new EntityReference(
Account.EntityLogicalName,
_accountId),
Status = new OptionSetValue((int)lead_statuscode.Qualified),
LeadId = new EntityReference(Lead.EntityLogicalName, _lead2Id)
};
var qualifyIntoOpportunityRes =
(QualifyLeadResponse)_serviceProxy.Execute(qualifyIntoOpportunityReq);
Console.WriteLine(" The second lead was qualified.");
foreach (var entity in qualifyIntoOpportunityRes.CreatedEntities)
{
NotifyEntityCreated(entity.LogicalName, entity.Id);
if (entity.LogicalName == Opportunity.EntityLogicalName)
{
_opportunityId = entity.Id;
}
}
从中获取此代码的示例具有更多详细信息:https://msdn.microsoft.com/en-us/library/hh547458.aspx。