Pre-Totals Script - Accessing Item Information Using oLines.GetChildHandle("ITEMCODE")


I have a script on the pre-totals event, that loops through any line items, and needs to get item related information for a given item. The problem I'm running into, is that in certain cases, the script runs, but the item information is returned as blank.

Here are the steps I can follow to reproduce this behavior. For an order with 1 item and 1 discount code:

1) Select the line with the discount code, and click the red "X" to delete this line

2) Select the line with the item, then select the now empty line under it

3) Click the totals tab to queue the pre-totals script

When I keep the lines as they are, or add on another item, my messageboxes correctly return the item and product line. However, when I follow the above steps, the message boxes still show, but the item and product line are blank. Any ideas on why in certain scenarios, the item and product line are not being properly accessed?

Here is my code where I've isolated the issue:

error_code = ""

retVal = ""

item_number = ""

Set oLines = oBusObj.AsObject(oBusObj.Lines)


Do until oLines.EOF

Set oItemCode = oBusObj.AsObject(oLines.GetChildHandle("ITEMCODE"))

error_code = oItemCode.GetValue("ProductLine$", product_line)

error_code = oItemCode.GetValue("ItemCode$", item_number)

msgbox("Item Number: " & item_number)

msgbox("Product Line: " & product_line)



Parents Reply Children