简体   繁体   English

如何在MS CRM中更新地址组合?

[英]How do I update address composite in MS CRM?

Problem I am trying to get my accounts to update the composite address with the new address. 问题我试图让我的帐户用新地址更新组合地址。 Al the fields in the customer address show the new values but the composite address shows the old address. A1中,客户地址中的字段显示新值,而复合地址中的字段显示旧地址。

Desired Result: Composite field updates to the new address upon changing the address fields 所需的结果:复合字段更改地址字段后更新到新地址

Actual Result: Composite field shows the old address 实际结果:复合字段显示旧地址

Things I've Tried: 我尝试过的事情:

  1. Updating the address 更新地址
  2. Deleting The Address and creating a new one (BAD IDEA) 删除地址并创建一个新地址(BAD IDEA)
  3. Setting all fields to the default values when the account was created 创建帐户时将所有字段设置为默认值
  4. Setting the composite field directly 直接设置复合字段
  5. Setting the version number to the default 0x00003F3F 将版本号设置为默认的0x00003F3F
  6. Setting all address fields to null 将所有地址字段设置为空

Current Code: 当前代码:

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

Question How do I successfully change the address composite field in Microsoft Dynamic CRM upon updating the address fields 问题如何在更新地址字段后成功更改Microsoft Dynamic CRM中的地址组合字段

You should update the address fields of the Account record, not the CustomerAddress. 您应该更新帐户记录的地址字段,而不是CustomerAddress。

ie

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

If this you're doing is a real-time operation of some kind taking place while the form is open, you also might need to invoke Xrm.Page.data.refresh(false) for the new data to show up. 如果您正在执行的操作是在打开表单时进行的某种实时操作,则可能还需要调用Xrm.Page.data.refresh(false)才能显示新数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为MS-CRM 2013的MS代理类添加接口 - How do I add an Interface to a MS Proxy Class for MS-CRM 2013 如何使用REST接口在MS CRM 2013中将OwnerId设置为BusinessUnitId? - How do I set an OwnerId to a BusinessUnitId in MS CRM 2013 using REST interface? 如何以编程方式复制具有复合键的MS Access表架构? - How do I programmatically copy MS Access table schema which has composite key? 如何从C#更新CRM 2011工作流插件的PrimaryEntity? - How do I update the PrimaryEntity of a CRM 2011 Workflow plugin from C#? CRM插件:更新帐户地址时如何更新关联联系人的地址 - CRM Plugin: how to update associated contacts' addresses when you update account address 如何检查复合ID是否存在? - How do I check composite ID exists? CRM 插件:如何在帐户创建后立即更新 email 地址 - CRM Plugin: how to update email address of account soon after its creation 如何在MS Dynamics CRM中通过QuoteDetail获取Opportunity产品? - How to get Opportunityproduct by QuoteDetail in MS Dynamics CRM? 如何在MS CRM中实施安全模型? - How to implement security model in MS CRM? 无法更新MS Dynamics CRM 2011工作流的电子邮件状态代码 - Cannot update Email statecode for a MS Dynamics CRM 2011 Workflow
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM