在 CRM Dynamics 2013 中,我如何检索帐户列表并针对特定用户创建 phone 呼叫活动

In CRM Dynamics 2013 how can I retrieve a list of accounts and create phone call activities against them for specific users

我有一个场景,我需要从 CRM 获取帐户列表,然后针对这些帐户创建 phone 调用活动,同时 assign/splitting 他们在四个不同的用户中,请参阅我的到目前为止的代码,请指导我找到针对这种情况的解决方案。

public static void CreatePhoneCallActivitesForRelatedAccount(IOrganizationService service)
    {
        QueryExpression qe = new QueryExpression();
        qe.EntityName = "account";
        qe.ColumnSet = new ColumnSet("new_accountactionedstatus");
        qe.Criteria.AddCondition("new_deliverystatus", ConditionOperator.Equal, 279640000);
        qe.Criteria.AddCondition("new_province", ConditionOperator.Equal, 100000018);
        qe.Criteria.AddCondition("statecode", ConditionOperator.Equal, 0);
        //qe.Criteria.AddCondition("ownerid", ConditionOperator.In, "6DEFA813-56F9-E411-80CC-00155D0B0C2D", "CBDD653B-57F9-E411-80CC-00155D0B0C2D", "6CE879FD-56F9-E411-80CC-00155D0B0C2D");

        EntityCollection response = service.RetrieveMultiple(qe);

        foreach (Entity account in response.Entities)
        {
            PhoneCall phonecall = new PhoneCall
            {
                // ToDo: How can I add a phone call activity and assign it to the above created Accounts, also to splitting them amongst 4 users in the system
            };
        }
    }

您可以使用以下代码:

Guid[] users = new Guid[] { <id1>, <id2>, <id3>, <id4>};

var counter = 0;

        foreach (Entity account in response.Entities)
        {
            PhoneCall phone = new PhoneCall();

            ActivityParty _from = new ActivityParty();
            phone.OwnerId =
            _from.PartyId = new EntityReference("systemuser", users[counter % 4]);

            ActivityParty _to = new ActivityParty();
            _to.PartyId = account.ToEntityReference();

            phone.From = new ActivityParty[] { _from };
            phone.DirectionCode = true;
            phone.Subject = "phone call trial";
            phone.To = new ActivityParty[] { _to };
            service.Create(phone);

            counter++;  
        }

只是好奇 - 您是否尝试过使用搜索引擎搜索答案?我在第一页找到了答案 - https://www.google.com.ua/?gfe_rd=cr&ei=7I1hVvX4PI2u8we4v6iQAw#q=Microsoft+CRM+2011+Create+PhoneCall+C%23