Entering a Document with all the options and multiple lines can be a lot of work, and sometimes similar Documents already exist in the system. This is often a reverse action of the Document History Pattern, but we can also copy the outstanding documents.
An explanation on the use of Copy Document Pattern is available at https://www.youtube.com/watch?v=aTiwroXwW_0&list=PLhZ3P-LY7CqmVszuvtJLujFyHpsVN0U_w&index=17.
An example of this is creating a Credit Memo from a Posted Sales Invoice where all the information is copied, including the Customer, Items, and the correct posting dates.
The Copy Document Pattern objects are a Processing Only Report that calls into an internal function called the Codeunit. The Report object needs to understand the valid options to copy the data around. We can, for example, copy a Posted Sales Shipment to a Sales Order, but we cannot copy a Sales Order to a Posted Sales Invoice.
The direction where we copy the data always needs to be an unprocessed document.
Unlike the posting pattern, we cannot only use TRANSFERFIELDS. We need to apply business logic that checks if the values are still valid. If we copy a document that has been in the archive for a year, the Product Master Data might be discontinued. Each Document has a unique set of validation protocols that follow functional data entry patterns. This protocol should be used in the Copy Document functions.
This following screenshot illustrates the validation logic to create a Sales Line:
This means that if the validation logic in the Document changes because we add fields or change the data entry order we need to change the Copy Document too.