Dynamics AX 2009:删除折扣和附加费用
本质上,我正在做的是:
- 在 SalesLine 表上插入、删除或更新时,我检查该行的 ProductCode 并确定是否适用折扣或杂项费用
- 我有费用的查找表和 我
- 进行任何更改时,我必须有效地删除折扣/费用,因为新修改的 SalesLine 可能不符合费用/折扣的条件
有执行上述操作的代码 - 但具有以下副作用:
- 如果我突出显示几行在 SalesTable 窗体上的网格中,然后单击工具栏的删除按钮,我收到错误。
- 该错误似乎是由我的代码删除某些项目引起的,然后表单在代码已删除这些行后还尝试删除这些行。
删除父行时删除按代码添加折扣或费用的最佳方法是什么,如果用户选择删除相同的行,则不会导致表单崩溃?
预先感谢,这件事让我发疯!
编辑:当缓存的表单记录尝试删除时,我收到的具体错误是这样的:
无法编辑订单行 (SalesLine) 中的记录。由于另一个用户进程删除该记录或更改一个或多个记录,因此发生更新冲突记录中有更多字段。
Essentially, what I'm doing is this:
- 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
- I have lookup tables for the charges and discounts
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除
added-by-code
折扣或费用的最明显方法是使用选项Cascade<将您的表添加到
salesLine
表的删除操作中/代码>。还要在表上创建与SalesLine
表的表关系。这样您的记录就会自动删除。如果折扣/费用存储为销售行,我不会这样做。该错误消息让我猜测,您在删除销售行时删除了其他销售行:
删除问题的更新:
SalesLine
删除方法中删除代码。salesLine
数据源删除方法中。The most obvious way to delete the
added-by-code
discounts or charges would be to add your table in the delete actions of thesalesLine
table with optionCascade
. Also make a table relation on your table to theSalesLine
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:
Update for the delete problem:
SalesLine
delete methods.salesLine
datasource delete method.