繁体   English   中英

Microsoft CRM Dynamics Online-如何检索活动列表并向其添加联系人

[英]Microsoft CRM Dynamics Online - How to retrieve a list of Campaigns and add a contact to it

首先,我是Microsoft Dynamics CRM 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。 这很完美。 我只想检索一个广告系列,然后将其附加到事件/活动中。

我的问题:我似乎无法获得一个广告系列列表,无法将它们添加到网页上,然后将该人附加到广告系列中。

我已经阅读了很多有关创建快速广告系列的文章,这些文章令人困惑。 我要实现的目标超出规范了吗? 还是不可能? 谁能为我提供一些代码,以使我朝正确的方向入门?

提前致谢

首先,您需要检索广告系列

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);

然后,您可以遍历此集合以获取所需的列表。

然后,在用户提交自定义表单(网络资源或其他应用程序)之后,您将需要在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);

这应该使您走上正确的路;)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM