Clone a DAC to insert a new DAC

爱⌒轻易说出口 提交于 2019-12-24 00:42:51

问题


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


来源:https://stackoverflow.com/questions/44881787/clone-a-dac-to-insert-a-new-dac

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!