2015-03-31 26 views
1

首先,我對Microsoft Dynamics CRM Online比較陌生。Microsoft CRM Dynamics Online - 如何檢索廣告系列列表並向其中添加聯繫人

我的目標:我想從我們的CRM中獲取當前活動活動(在我的情況下是活動列表)列表,並將其列在預訂表格的下拉列表中。然後,我想要一個人填寫表格並選擇他們想參加的活動。點擊提交後,將在CRM中創建一個聯繫人,並且該人將作爲參加者加入「回覆」部分。

我有什麼至今:

public void Run(String connectionString, String AddDetails) 
    { 
     try 
     { 
      // Establish a connection to the organization web service using CrmConnection. 
      Microsoft.Xrm.Client.CrmConnection connection = CrmConnection.Parse(connectionString); 

      // Obtain an organization service proxy. 
      // The using statement assures that the service proxy will be properly disposed. 
      using (_orgService = new OrganizationService(connection)) 
      { 
       // Instantiate an account object. 
       Entity account = new Entity("contact"); 

       // Set the required attributes. For account, only the name is required. 
       // See the metadata to determine 
       // which attributes must be set for each entity. 
       account["lastname"] = AddDetails; 

       _orgService.Create(account); 
      } 
     } 

        // Catch any service fault exceptions that Microsoft Dynamics CRM throws. 
     catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>) 
     { 
      // You can handle an exception here or pass it back to the calling method. 
      throw; 
     } 
    } 

我可以創建聯繫人和檢索此記錄的唯一ID。這工作完美。我只想檢索廣告系列並將其附加到下一個活動/廣告系列。

我的問題:我似乎無法獲取廣告系列列表,將它們添加到網頁中,然後將此人附加到廣告系列。

我已經閱讀了不少文章來創建令人困惑的快速廣告系列。我正在努力達到什麼標準?或不可能?任何人都可以提供一些代碼讓我開始正確的方向嗎?

在此先感謝

+0

我想你可以做的最好的事情就是閱讀擴展章節,你正在談論很多事情,但它們必須一個接一個,一個是客戶端代碼(Javascripts,WebResources),另一個是插件,工作流程,通過rest或soap調用IOrganizationService。有很多方法可以滿足您的需求,但我認爲您需要知道您要做什麼以及爲什麼要這樣做。 – Sxntk 2015-04-06 19:14:24

+0

非常感謝您的建議。我認爲這可能是我發佈這個問題後得到的答案。我希望完成具體任務。不過,我會走開並詳細瞭解有關的主題領域。 – PhilC 2015-04-13 17:09:40

回答

0

首先,你需要獲取廣告活動

QueryExpression qe = new QueryExpression("campaign"); 
qe.ColumnSet = new ColumnSet(true); // this will retrieve all fields, you should only retrieve attribute you need ;) 

EntityCollection collection = _orgService.RetrieveMultiple(qe); 

然後你可以遍歷這個集合,讓你需要的資源列表。

然後你的用戶後提交的自定義窗體或者webresource或其他一些應用程序,你需要創建在CRM

var campaignResponse = new Entity("campaignresponse"); 
campaignResponse["regardingobjectid"] = new EntityReference("campaign", YOUR CAMPAIGN GUID); 
campaignResponse["customer"] = new EntityReference("lead/account/contact", RECORDGUID); 
_orgService.Create(campaignResponse); 

這應該讓你在正確的軌道上活動響應;)

相關問題