Dynamics AX 2009:删除折扣和附加费用

发布于 2024-12-12 14:26:02 字数 575 浏览 0 评论 0原文

本质上,我正在做的是:

  1. 在 SalesLine 表上插入、删除或更新时,我检查该行的 ProductCode 并确定是否适用折扣或杂项费用
  2. 我有费用的查找表和 我
  3. 进行任何更改时,我必须有效地删除折扣/费用,因为新修改的 SalesLine 可能不符合费用/折扣的条件

有执行上述操作的代码 - 但具有以下副作用:

  • 如果我突出显示几行在 SalesTable 窗体上的网格中,然后单击工具栏的删除按钮,我收到错误。
  • 该错误似乎是由我的代码删除某些项目引起的,然后表单在代码已删除这些行后还尝试删除这些行。

删除父行时删除按代码添加折扣或费用的最佳方法是什么,如果用户选择删除相同的行,则不会导致表单崩溃?

预先感谢,这件事让我发疯

编辑:当缓存的表单记录尝试删除时,我收到的具体错误是这样的:

无法编辑订单行 (SalesLine) 中的记录。由于另一个用户进程删除该记录或更改一个或多个记录,因此发生更新冲突记录中有更多字段。

Essentially, what I'm doing is this:

  1. On insert, delete, or update on the SalesLine table, I'm checking the ProductCode of that line and determining whether or not a discount or miscellaneous charge applies
  2. I have lookup tables for the charges and discounts
  3. When any changes are made, I have to effectively remove the discounts/charges, because the newly modified SalesLine might not qualify for the charges/discounts

I have code that is doing what is described above -- but with the following side-effect:

  • If I highlight several lines in the grid on the SalesTable Form, and click the toolbar's delete button, I get errors.
  • The error(s) seem to be caused by my code deleting some of the items, and then the form is also trying to delete the lines after they've already been deleted by the code.

What would be the best way to erase the added-by-code discounts or charges when the parent line is deleted, that won't cause the form to blow up if a user selects those same lines for deletion?

Thanks in advance, this thing is driving me crazy!

EDIT: The specific error that I receive when the cached Form records try to get deleted is this:

Cannot edit a record in Order lines (SalesLine).An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

So尛奶瓶 2024-12-19 14:26:03

删除added-by-code折扣或费用的最明显方法是使用选项Cascade<将您的表添加到salesLine表的删除操作中/代码>。还要在表上创建与 SalesLine 表的表关系。这样您的记录就会自动删除。如果折扣/费用存储为销售行,我不会这样做。

该错误消息让我猜测,您在删除销售行时删除了其他销售行:

  1. 删除“真实”销售行时,您删除了折扣或收费行。
  2. 进行多行删除时,#2 行已被#1 行删除删除,但表单缓冲区尚未更新,删除失败。这实际上是错误消息告诉您的内容,自从表单读取记录以来,一行已更新。

删除问题的更新:

  1. SalesLine 删除方法中删除代码。
  2. 创建一组稍后删除的recId,填充到salesLine数据源删除方法中。
  3. 如果该集合不为空,请稍后删除这些行(可能是从活动方法中)。

The most obvious way to delete the added-by-code discounts or charges would be to add your table in the delete actions of the salesLine table with option Cascade. Also make a table relation on your table to the SalesLine talbe. In this way your records are deleted automatically. I would not do this if the discounts/charges are stored as sales lines though.

The error message make me guess, that you delete other sales lines, when deleting a sales line:

  1. When deleting a "real" sales line you delete discount or charge lines.
  2. When doing multi-line delete the #2 line has been deleted by the #1 line delete, but the form buffer has not been updated and the delete fails. This is effectively what the error messages tells you, a line has been updated since the record was read by the form.

Update for the delete problem:

  1. Remove your code from the SalesLine delete methods.
  2. Create a set of recId to be deleted later, populate in the salesLine datasource delete method.
  3. Delete the lines later (maybe from the active method), if the set is not null.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文