动态CRM 2016创建和资格的首席编程C#

动态CRM 2016创建和资格的首席编程C#

问题描述:

我试着以编程方式创建一个牵头实体,我已阅读,有没有特殊的领域比较特殊的消息在动态CRM 2016年动态CRM 2016创建和资格的首席编程C#

所以,我检索数据从Dynamics CRM服务器,我将其插入annother CRM服务器,而无需使用特殊的消息就像下面:

account["statecode"] = new OptionSetValue(1); //inactive 
account["statuscode"] = new OptionSetValue(2); //inactive 

的问题是,有一个值“1” statecode至极意味着是一个合格的潜在顾客记录铅和一个statuscode,其值为“3”,这也意味着合格。

任何方式,当我试图做插入与流动的消息引发的错误:

3 is not a valid status code for state code LeadState.Open

仅供参考,LeadState.Open的值为“0”,即使领先状态,因为我之前提到是“1”。

我不知道什么是exatley的问题。

预先感谢您。

您应该使用SDK中记录的QualifyLeadRequest。此消息与SetState不同,未被标记为弃用。资格牵头工作流程比设置状态流程更复杂,因为它包含(可选)创建和链接到帐户,联系人和商机记录。

下面是一个SDK的例子,该SDK定义了一个潜在客户,并创建一个opportunity与现有的account

  // 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

+0

好的,谢谢! –