本文介绍了克隆DAC以插入新的DAC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Acumatica Framework中创建DAC的副本(即克隆它)。我当然可以创建一个新实例并单独设置所有值,但是有没有一种方法可以为您呢?

How to create a copy of a DAC (i.e. cloning it) in Acumatica Framework. I can of course create a new instance and set all the value individually but is there a method which does this for you?

我发现了以下方法

PXCache<...>.CreateCopy(sourceRule);

但是,这似乎可以复制所有内容,包括ID,CreatedBy等。
需要一个 DAC,并复制所有相关字段。
如何操作?

However, this seems to copy everything, including the ID, CreatedBy etc.I would need a new DAC, with all relevant fields copied.How to do this please?

推荐答案

您可以使用 PXCache CreateCopy 执行您所提到的复制,然后在将新副本插入到缓存中之前先将其空/更改键。

You can use PXCache CreateCopy to perform the copy like you mentioned, then null/change the keys before inserting the new copy into the cache.

这里有一个示例,该示例会将销售行复制为销售订单扩展中的新行:

Here is an example that will copy a sales line as a new line on a sale order extension:

var soLine = PXCache<SOLine>.CreateCopy(Base.Transactions.Current);
// Null the keys of SOLine
soLine.OrderType = null;
soLine.OrderNbr = null;
soLine.LineNbr = null;
Base.Transactions.Insert(soLine);

这篇关于克隆DAC以插入新的DAC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-17 00:09