【问题标题】:how to get reference id of contact when account is update contact should be also update帐户更新时如何获取联系人的参考ID联系人也应该更新
【发布时间】:2016-10-06 06:26:48
【问题描述】:
 if (entity.LogicalName == "account")
            {
                Entity Account = (Entity)service.Retrieve(context.PrimaryEntityName, context.PrimaryEntityId, new ColumnSet(true));
                tracingService.Trace("1");
                Guid ContactGuid = Account.Id;
                tracingService.Trace("9");
                //throw new Exception("Contact guid" + ContactGuid);
                Entity objContact = (Entity)service.Retrieve("contact", ((EntityReference)Account.Attributes["new_account"]).Id, new ColumnSet(true));
                tracingService.Trace("2");
                string Updatename = Account.GetAttributeValue<string>("name");
                tracingService.Trace("3");
                objContact.Attributes["fullname"] = Updatename;
                tracingService.Trace("4");
                string Updateemail = Account.GetAttributeValue<string>("emailaddress1");
                tracingService.Trace("5");
                objContact.Attributes["emailaddress1"] = Updateemail;
                tracingService.Trace("6");
                string Updateaddress = Account.GetAttributeValue<string>("address1_composite");
                tracingService.Trace("7");
                objContact.Attributes["address1_composite"] = Updateaddress;

                service.Update(objContact);
            }

【问题讨论】:

  • 请更详细地描述您的问题。在当前状态下,您的意思绝对不清楚。
  • 我正在尝试在帐户更新和联系人更新时创建联系人记录......

标签: c# dynamics-crm


【解决方案1】:

假设您要获取帐户的主要联系人的 ID:

EntityReference primaryContact = Account.GetAttributeValue<EntityReference>("primarycontactid");
Guid contactGuid = primaryContact.Id;

请注意,该帐户的所有联系人的关系 contact_customer_accounts 是 1:N,因此您需要从关系中检索它们并循环它们。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-09
    • 2018-01-25
    • 1970-01-01
    • 1970-01-01
    • 2018-02-22
    • 1970-01-01
    • 1970-01-01
    • 2015-07-01
    相关资源
    最近更新 更多