Duplicate Invoice

The primary issue we face when duplicating orders is dealing with line items. Some methods export line items out to a temp table then reimport them. Other methods loop through line items duplicating and resetting the order ID.

This method circumvents this issue. It requires one field in the line item table. The field will concatenate all the line item fields.

Concatenate all the necessary field

zItemStringForDup [ ItemNbr & "|" & Qty & "|" & Size & "|" & Quote ( Description ) & "|" & Style & "|" & Medium & "|" & Label & "|" & Price & "|" & OceanFreight & "|" & Item_Duty & "|" & WD ]

Use Quote() around any field the could have returns


This method also incorporates another Tip • Create Records without leaving home*

Script - Duplicate Invoice

The first step is to get a list of the Line Items you need to duplicate.

Set Variable [ $$ItemDup; Value:List ( Orders_OrderLI|OrderID::zItemStringForDup ) & ¶ ]
Set Variable [ $CT; Value:PatternCount ( $ItemDup ; ¶ ) ]
Set Variable [ $CTR; Value:1 ]
Loop
        Set Variable [ $ItemToCreate; Value:Substitute ( GetValue ( $$ItemDup ; $CTR ) ; "|" ; ¶ ) ]
        Set Field [ Orders::zgCR_Nav; "" ]* //Create Records trick starts here
        Set Field [ Orders_OrderLI|CR_Nav::OrderID; Orders::OrderID ]
        Commit Records/Requests
        Set Field [ Orders_OrderLI|CR_Nav::ItemNbr; GetValue ( $ItemToCreate ; 1 ) ]
        Set Field [ Orders_OrderLI|CR_Nav::Qty; GetValue ( $ItemToCreate ; 2 ) ]
        Set Field [ Orders_OrderLI|CR_Nav::Size; GetValue ( $ItemToCreate ; 3 ) ]
        Set Field [ Orders_OrderLI|CR_Nav::Description; Substitute ( GetValue ( $ItemToCreate ; 4 ) ; "\"" ; "" ) ]
          The above step removes the quotes that the Quote() functon put around the field data...
        Set Field [ Orders_OrderLI|CR_Nav::Style; GetValue ( $ItemToCreate ; 5 ) ]
        Set Field [ Orders_OrderLI|CR_Nav::Medium; GetValue ( $ItemToCreate ; 6 ) ]
        Set Field [ Orders_OrderLI|CR_Nav::Label; GetValue ( $ItemToCreate ; 7 ) ]
        Set Field [ Orders_OrderLI|CR_Nav::Price; GetValue ( $ItemToCreate ; 8 ) ]
        Set Field [ Orders_OrderLI|CR_Nav::OceanFreight; GetValue ( $ItemToCreate ; 9 ) ]
        Set Field [ Orders_OrderLI|CR_Nav::Item_Duty; GetValue ( $ItemToCreate ; 10 ) ]
        Set Field [ Orders_OrderLI|CR_Nav::WD; GetValue ( $ItemToCreate ; 11 ) ]
        Commit Records/Requests
        Exit Loop If [ $CTR ≥ $CT ]
        Set Variable [ $CTR; Value:$CTR + 1 ]
End Loop