2015-03-31 27 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); 

这应该让你在正确的轨道上活动响应;)

相关问题