簡體   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