0

我正在尝试为我尝试使用创建的产品包设置默认价目表Microsoft.CrmSdk.CoreAssemblies。我已经编写了工作代码,该代码使用我在代码中指定的所有配置成功创建了产品捆绑包,但从未设置默认价目表。以下是代码片段:

  Entity ProductBundleEntity = new Entity("product");
                ProductBundleEntity.Attributes["name"] = Name;
                ProductBundleEntity.Attributes["productstructure"] = new OptionSetValue(3);
                ProductBundleEntity.Attributes["productnumber"] = Guid.NewGuid().ToString();
///// setting defult price list here
                ProductBundleEntity.Attributes["pricelevelid"] = new EntityReference("pricelevel", PriceListID);
                ProductBundleEntity.Attributes["defaultuomscheduleid"] = new EntityReference("uomschedule", UOMScheduleID);
                ProductBundleEntity.Attributes["defaultuomid"] = new EntityReference("uom", UOMID);

请建议我是否缺少任何东西。

4

2 回答 2

1

您收到任何错误吗?您的插件何时运行,创建/更新?是同步的吗?– 是术前还是术后?

如果发布您可能必须使用 service.update(Entity object) 最好尝试使用 pre 操作,以便可以使用相同的对象/。

于 2020-06-24T12:28:42.253 回答
0

虽然我不知道 PriceListId 变量的定义,但通常你需要分配一个 id,如下所示,我认为 PriceListId 变量不包含值;

ProductBundleEntity.Attributes["pricelevelid"] = new EntityReference("pricelevel", ((Microsoft.Xrm.Sdk.EntityReference)(originalEntity.Attributes["pricelevelid"])).Id);

于 2020-06-24T11:37:52.213 回答