Create Script to Explode a Kit on a Sales Order

SOLVED

I've created a script to add line items to a Sales Order, but adding a kit using the same method does not explode the kit as it should. Should Kit items still be added to the line item (oLines) array on the SalesOrder object, or should some other function be called to explode the line items first, then add them?

(edit: I have already purchased the BOI course and have reviewed the documentation - there is no information there about adding kits that I could find.)

Thank you for any help.

-Danielle

  • +1
    verified answer

    When adding the line for the kit, set ExplodedKitItem$ to "Y".  When the Write() is done for that line the kit lines will be exploded into the order detail.

  • 0 in reply to Steve Passmore

    Thanks for the quick reply! 

    Here's a snippet of code for where I'm adding the line item:

    If CBool(oSOOrder.nAddLine()) Then
    Dim LineKey As String = oSOOrder.oLines.sGetKey()
    Dim QuantityOrdered As Decimal = CType(quantity, Decimal)

    If CBool(oSOOrder.oLines.nSetValue("ItemCode$", lineitem)) Then

    If CBool(oSOOrder.oLines.nSetValue("ExplodedKitItem$", "Y")) Then

    ...

    For some reason now when I run the script, I get this error:

    "Could not create Sales Order Object:  You are not authorized to access this program."

    Does the current line key need to be passed as a 3rd parameter when setting the ExplodedKitItem$ attribute?

    Thank you again for your help!
    Danielle

  • +1 in reply to Danielle E
    verified answer

    The SetValue() you have for setting ExplodedKitItem$ is good, no additional argument is necessary.

    Can you identify exactly what code is returning the error message?

  • 0 in reply to Steve Passmore

    Hi Steve, I was able to narrow down the issue and the error was being thrown because I was setting the ExplodingKitten er... ExplodedKitItem$ attribute for each line item, not just the 1 kit line item. After correcting my script, it runs perfectly. Thank you for your help and follow up!