且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Acumatica-复制最后一行

更新时间:2023-11-29 23:12:22

如果只想一行并复制所有值,则可以使用缓存复制和空行号。然后在插入复制的行时,它将自动获得下一个linenbr ...在您的问题中添加到示例代码中。

If you just want to take the line and copy all values you can use cache copy and null the lineid. Then on insert of the copied line it will get the next linenbr automatically... adding to your sample code in your question...

SOLine line = Base.Transactions.Select().LastOrDefault();
var copy = (SOLine)Base.Transactions.Cache.CreateCopy(line);
copy.LineNbr = null;
Base.Transactions.Cache.Insert(copy);

如果在SOLine中添加了新字段或自定义项,则此方法也应该易于升级复制而不必选择性地包括要复制的所有字段(使用CreateCopy)。

This method should also be upgrade friendly in the event new fields or customization are added to SOLine they will continue to be copied without having to selectively include all fields to be copied (using CreateCopy).