0

We would like to copy current row in acumatica via button in Purchase Orders screen. I asked question about that earlier in Acumatica - Copy last row

None of the solutions work anymore in 2020 R1, build 20.104.0012. It appears that NoteID needs to be set to null, in addition to line ID. Ilya's solution in the link above does not create the second line at all, after the PressSave is run. Brandon's solution generates "An item with the same key has already been added." error. My updated action is below:

public PXAction<POOrder> copyRow;
[PXButton]
[PXUIField(DisplayName = "Copy Row")]
protected virtual IEnumerable CopyRow(PXAdapter adapter)
{
    var row = Base.Transactions.Current;

    var rowCopy = Base.Transactions.Cache.CreateCopy(row) as POLine;
    rowCopy.LineNbr = null;
    rowCopy.NoteID = null;
    rowCopy = Base.Transactions.Insert(rowCopy);
    return adapter.Get();
}

Please advise.

Stan A
  • 133
  • 8
  • I can't address why it isn't working now, but to be able to move on for now, you could manually copy each field. Start with **POLine rowCopy = Base.Transactions.Insert();** and then set each field explicitly. The *Insert* will handle the key fields, LineNbr, and NoteID for you, and then you can fill in the blanks from there. Finish with **Base.Transactions.Update(rowCopy);** – Brian Stevens Oct 25 '20 at 13:35
  • sorry, did not understand what error are you getting since your code is slightly different than the other answers. Can you clarify? Also if you set a breakpoint at return, can you check whether the LineNbr property is populated or is it still null? – Joseph Caruana Oct 28 '20 at 20:38

0 Answers0