【问题标题】:How do I update address composite in MS CRM?如何在 MS CRM 中更新地址组合?
【发布时间】:2017-07-21 16:43:23
【问题描述】:

问题 我正在尝试让我的帐户使用新地址更新复合地址。客户地址中的所有字段都显示新值,但复合地址显示旧地址。

期望的结果: 更改地址字段时复合字段更新为新地址

实际结果: 复合字段显示旧地址

我尝试过的事情:

  1. 更新地址
  2. 删除地址并创建一个新地址(坏主意)
  3. 在创建帐户时将所有字段设置为默认值
  4. 直接设置复合字段
  5. 将版本号设置为默认0x00003F3F
  6. 将所有地址字段设置为空

当前代码:

    Entity theAccount = proxy.Retrieve("account", Guid.Parse("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"), new Microsoft.Xrm.Sdk.Query.ColumnSet(true));
Guid address1_id = theAccount.Attributes.ContainsKey("address1_addressid") ? (Guid)theAccount.Attributes["address1_addressid"] : Guid.Empty;

Entity theAddress = new Entity()
{
    LogicalName = "customeraddress",
    Id = address1_id
};
theAddress.Attributes["line1"] = null;
theAddress.Attributes["line2"] = null;
theAddress.Attributes["line3"] = null;
theAddress.Attributes["city"] = null;
theAddress.Attributes["stateorprovince"] = null;
theAddress.Attributes["country"] = null;
theAddress.Attributes["county"] = null;
theAddress.Attributes["postofficebox"] = null;
theAddress.Attributes["postalcode"] = null;
theAddress.Attributes["composite"] = null;

proxy.Update(theAddress);

theAddress.Attributes["line1"] = "1 New Street";
theAddress.Attributes["line2"] = null;
theAddress.Attributes["line3"] = null;
theAddress.Attributes["city"] = "New City";
theAddress.Attributes["stateorprovince"] = "New State";
theAddress.Attributes["country"] = "New Country";
theAddress.Attributes["county"] = null;
theAddress.Attributes["postofficebox"] = null;
theAddress.Attributes["postalcode"] = "1234";

proxy.Update(theAddress);

问题 如何在更新地址字段时成功更改 Microsoft Dynamic CRM 中的地址复合字段

【问题讨论】:

  • 第二次Update后检索记录时,复合字段仍为空?

标签: c# dynamics-crm


【解决方案1】:

您应该更新客户记录的地址字段,而不是客户地址。

Entity theAccount = new Entity("account", "XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXX");

theAccount["address1_line1"] = null;
theAccount["address1_line2"] = null;
theAccount["address1_line3"] = null;
theAccount["address1_city"] = null;
theAccount["address1_stateorprovince"] = null;
theAccount["address1_country"] = null;
theAccount["address1_county"] = null;
theAccount["address1_postofficebox"] = null;
theAccount["address1_postalcode"] = null;
theAccount["address1_composite"] = null;

proxy.Update(theAccount);

theAccount["address1_line1"] = "1 New Street";
theAccount["address1_line2"] = null;
theAccount["address1_line3"] = null;
theAccount["address1_city"] = "New City";
theAccount["address1_stateorprovince"] = "New State";
theAccount["address1_country"] = "New Country";
theAccount["address1_county"] = null;
theAccount["address1_postofficebox"] = null;
theAccount["address1_postalcode"] = "1234";

proxy.Update(theAccount);

如果您正在执行的操作是在表单打开时进行的某种实时操作,您可能还需要调用 Xrm.Page.data.refresh(false) 以显示新数据。

【讨论】:

  • 非常感谢。我被困在必须清除客户地址而不是帐户上。坚持了一周:S
猜你喜欢
  • 2018-11-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多