The following SQL code when creating or editing 1 document generates 2, based on the contents of a custom item field.

So when the custom field has the value ‘111’ the item goes to 1 document, when the value ‘222’ goes to 2.

 

This code should be pasted in the corresponding document at:

Settings->Purchases/Sales->Documents->Run SQL

 

For sale with automatic issue of 2 documents with line number 104: