oShipLines.nCopyLinesFromSalesOrder(soOrder) is copying an extra line

SOLVED

Hi Forum,

I am using .nCopyLinesFromSalesOrder(soOrder) to bring in all lines from the Sales Order into Shipping Invoice data entry and every order I import is duplicating the lines.

Any advice on this will be greatly appreciated.

Regards,

Manuel

Top Replies

  • +1
    verified answer

    , I believe when you do the .nSetValue("SalesOrderNo$", soOrder) to the invoice header object, it uses that CopyLinesFromSalesOrder() method to copy the lines within the validation of the Sales Order number.  So if you do it manually after, you'll get the duplicate lines, so try leaving out your call and let the validation of the sales order do that.

    Hope that helps

    Elliott

  • 0 in reply to jepritch

    Thanks Elliot, appreciated.

    Regards,

  • 0 in reply to jepritch

    It did work... Thanks again.

    Regards,

  • 0 in reply to jepritch

    Elliott,

    Do you know of an easy way to pull in the missing lines from the SO (not in the invoice source file used by VI), so those un-invoiced lines are back-ordered properly?  I experimented a bit with a similar CopyLinesFromSalesOrder strategy (using VI PerformLogic) and had the same problem with duplicate lines.

    I could probably write a PreTotals script, but that would require looping through the invoice lines multiple times (for each SO line), which would slow down the import for large orders / invoices.

  • 0 in reply to Kevin M

    Hey Kevin,

    Not sure how your import works, but you would need the sales order line key when adding the invoice line so that the 2 are married up.  If you have that, you could maybe keep track of the SO Line Keys in a storage var, then on the pre-write of the invoice itself, you could go through the sales order and add in the lines that do not have their line key in your string of lines stored in the storage var (use oSession storage btw).  This would alleviate having to make multiple loops through the invoice lines.

    Not sure if I fully grasp everything.  The only issue with my method would be the lines will be in a different order than the sales order.

    I haven't tried this obviously, but sounds like it might work.  If you want to email me more details maybe we can work it out.  Should be possible without having to loop too many times on the lines.

    E

  • 0

    It sounds like the .nCopyLinesFromSalesOrder(soOrder) method is duplicating lines when you import them from the Sales Order into the Shipping Invoice in your system. This could be due to a few reasons, such as issues with how the method is called or a potential bug in the script.

    Here are a few steps you can take to troubleshoot and resolve this issue:

    1. Check How the Method is Called: Make sure that the method .nCopyLinesFromSalesOrder(soOrder) isn't being called more than once in your script or workflow inadvertently.

    2. Review the Method's Configuration: Sometimes, methods like these can have configuration settings or parameters that determine how they operate. Ensure there are no settings that might cause line duplication.

    3. Examine Event Triggers: If this method is triggered by an event (like a button press or a field update), ensure the event is not firing multiple times. For example, a button might be clicked twice, or a field update might be triggering the method unexpectedly.

    4. Look for Loops: If the method call is inside a loop, make sure the conditions governing the loop are correct and not resulting in repeated method calls for the same order.

    5. Check for Software Bugs: There might be a bug in the software you are using. Review the software's documentation or support forums for any known issues. Contacting support with a detailed description of your issue might also uncover a solution.

    6. Log and Debug: Add logging before and after the method call to see exactly when it's called. This might help you identify unwanted multiple executions.