c# - 从 CRM 门户 (2011) 保存相关属性(Lead_PhoneCall 事件)时出错?

标签 c# asp.net dynamics-crm-2011 dynamics-crm crm

我正在尝试在 Regarding Field of PhoneCall Activity 中保存 Lead Guid, 它给出了一个错误 - 仅“regardingobjectid”。 [前提]

请帮忙!

在 New_PhoneCall.cs 页面中:

PhoneCall_Save.regardingobjectid = Guid.Parse(hdnfld_regarding.Value);//(hdnfld_regarding 是一个隐藏字段,其中 m 传递 guid,我已经将其与文本框一起使用)

在 AppCode/CRMDMLibrary.cs 中:

    public class PhoneEntity
    {
       public Guid regardingobjectid;
    }

    public bool SaveNewPhoneCall()
    {
        try
        {
            IOrganizationService Context = CRMDMLibrary.GetCRMService(url, DomainName, username, password);

            Entity Phone = new Entity("phonecall");

            Phone["regardingobjectid"] = new EntityReference("regardingobject", regardingobjectid);

            Guid phoneid = Context.Create(Phone);
            return true;
        }
        catch (Exception ex)
        {
            HttpContext.Current.Response.Write(ex.Message);
            HttpContext.Current.Response.End();
            return false;
        }

    }

最佳答案

传递 regardingobject 作为 EntityReference 是错误的。你应该传递 lead 作为 实体引用

 Phone.Attributes["regardingobjectid"] = new EntityReference("lead", regardingobjectid);

还要检查 lead id 的来源

关于c# - 从 CRM 门户 (2011) 保存相关属性(Lead_PhoneCall 事件)时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27016346/

相关文章:

c# - 将 GPS 解析为度数

sql - 该模型已有一个同名元素 - ASP.NET

javascript - JQuery:on 无法正常工作

linq - 在 LINQ 查询中使用组

javascript - 如何使用 SOAP 响应绑定(bind) HTML 表

c# - 使用MinHash查找2张图像之间的相似性

C# 脚本导致 Unity 编辑器崩溃

asp.net - 即使为空,复选框也会绑定(bind)(数据表控件)

dynamics-crm-2011 - 导入失败 - ID 不存在的角色

c# - 套接字在一端断开连接,防火墙吗?