【问题标题】:Dynamics CRM 2011 Plugin : Create New Phone Call After Complete An Old Phone CallDynamics CRM 2011 插件:完成旧电话后创建新电话
【发布时间】:2015-01-03 19:59:25
【问题描述】:

我想创建一个新插件,以便在上次通话状态即将完成时创建新电话。

我正在编写下面的代码,但它会创建重复键异常...

if (entity.Attributes.ContainsKey("statuscode") &&
   ((OptionSetValue)entity.Attributes["statuscode"]).Value == 2)
    {
        if (preTarget != null)
        {
            try
            {

                 var newCall = new Entity("phonecall");

                 newCall.Attributes.Add("to", preTarget.Attributes["to"]); 

                 newCall.Attributes.Add("from", preTarget.Attributes["from"]);

                 newCall.Attributes.Add("subject", preTarget.Attributes["subject"]);

                 newCall.Attributes.Add("ownerid", preTarget.Attributes["ownerid"]);

                 organizationService.Create(newCall);

        }
        catch (Exception exception)
        {

           throw new InvalidPlugiExecutionException(exception.Message, exception);
        }
    }
}

【问题讨论】:

    标签: dynamics-crm-2011 microsoft-dynamics


    【解决方案1】:

    您将不得不更改往返字段的方法。尝试对 to 和 from 字段使用以下代码:

    if (preTarget.Contains("to"))
    {
    Entity to1 = new Entity("activityparty");
    to1["partyid"] = preTarget.getAttributeValue<EntityCollection>("to").Entities[0]["partyid"];
    
    newCall["to"] = new Entity[] { to1 };
    }
    

    【讨论】:

      猜你喜欢
      • 2013-10-20
      • 1970-01-01
      • 1970-01-01
      • 2013-01-19
      • 1970-01-01
      • 2012-11-13
      • 2012-05-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多