2017-04-19 111 views
0

我試着以編程方式創建一個牽頭實體,我已閱讀,有沒有特殊的領域比較特殊的消息在動態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的問題。

預先感謝您。

回答

2

您應該使用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

好的,謝謝! –