-->

Clone a DAC to insert a new DAC

2019-07-19 09:20发布

问题:

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?

I found the following method

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

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?

回答1:

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);


标签: acumatica