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

本文关键字:列表 活动 电话 创建 用户 2013 Dynamics CRM 检索 何检索 | 更新日期: 2023-09-27 18:25:35

我有一个场景,我需要从CRM中获得一个帐户列表,然后针对这些帐户创建电话活动,并在四个不同的用户之间分配/拆分它们,请查看我目前的代码,并指导我找到该场景的解决方案。

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

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

您可以使用以下代码:

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