Search code examples
classmethodsaxaptadynamics-ax-2012

Use copy method on Docu class


When i create a Sales Order from a Customer i want to copy the document handling records from the customer to the Sales Order.

Therefore i want to use the copy method which exists on the Docu class.

I am not sure how to implement this in the SalesTable, i want to run this method after insert() on the SalesTable

I have tried to make a start with the following code:

if (CustTable::find(this.CustAccount))
{
    Docu::copy(_from, this.SalesId)
}

But i am stuck how to accomplish this.

The 2nd step is that i only want to copy documents with a specificed Document direction, but i guess i can figure that out once i know the right way to copy the documents.


Solution

  • The copy method expects two records.

    After the super() in SalesTable.insert you can do this:

    Docu::copy(this.custTable_CustAccount(), this);