• Toll-free  888-665-8637
  • International  +1 717-220-0012
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

WestmarketJames
#1 Posted : Monday, March 10, 2008 10:09:55 AM(UTC)
WestmarketJames

Rank: Member

Joined: 3/10/2008(UTC)
Posts: 5

Hello,

Can someone point me in the direction of how to fix this?

All I'm trying to do is just show a list of all of our orders with all of their lineitems within:

Order.ordernumber 001
LineItem.productname 001
LineItem.productname 002
LineItem.productname 003
Order.ordernumber 002
LineItem.productname 001
LineItem.productname 002
etc.

Code:

'lst is the listbox that will contain the items
'bvServices and bvToken are declared globally
protected sub(cmdShowOrdersAndDetails_Click(byval sender as object, byval e as system.eventargs) handles cmdShowOrdersAndDetails.click)

dim c as bvWeb3.OrderSearchCriteria
dim bvin as string = ""
c.isplaced = true

dim bvOrders() as bvWeb3.order = bvServices.Orders_order_findbycriteria(bvToken, c)
dim bvLineItem as new bvWeb3.lineitem

if bvOrders isnot nothing then
for i as integer = 0 to bvOrders.length - 1
lst.items.add(bvOrders(i).ordernumber)
bvin = bvOrders(i).bvin
bvLineItem = bvServices.orders_order_getlineitem(bvToken, bvOrders(i), bvin)
lst.items.add(" " & bvLineItem.productname)
next
end if
end sub


This is missing the second loop to go through the LineItems, but I can't even get the first lineitem to come up. The error message is "Object reference not set to an instance of an object." and the error points to the lst.items.add(" " & bvLineItem.productname line of code. The Immediate Window in vb.net shows that bvLineItem is nothing at this point. bvOrder(0) contains all the order information, but bvOrder(0).items has a length of 0.

Using a direct database query and not using the bv webservices, I can easily get the contents of the order, but I am wondering what I am doing wrong using the services.

Thanks for any help in advance.
Andy Miller
#2 Posted : Monday, March 10, 2008 2:56:10 PM(UTC)
Andy Miller

Rank: Member

Joined: 11/5/2003(UTC)
Posts: 2,136

Was thanked: 1 time(s) in 1 post(s)
Orders_Order_FindByCriteria returns an array of "lite" orders. Only the simple properties are filled in (bvin, ordernumber, etc). To retrieve the full order, including the lineitems, use Orders_Order_Load (I think that is the name). For example (I'm doing this from memory so there are probably misspellings),

dim bvOrders() as bvWeb3.order = bvServices.Orders_order_findbycriteria(bvToken, c)
dim bvLineItem as new bvWeb3.lineitem

if bvOrders isnot nothing then
for i as integer = 0 to bvOrders.length - 1
dim bvOrder as bvWeb3.order = bvServices.Orders_order_lod(bvToken, bvOrders(i).bvin)
lst.items.add(bvOrders(i).ordernumber)
bvin = bvOrders(i).bvin
For each lineitem as bvWeb3.LineItem in bvOrder.Items
lst.Items.Add(" " & lineitem.ProductName)
Next
next
end if
end sub
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing
WestmarketJames
#3 Posted : Wednesday, March 12, 2008 10:08:53 AM(UTC)
WestmarketJames

Rank: Member

Joined: 3/10/2008(UTC)
Posts: 5

I tried Orders_LineItem_FindByOrderId and was able to get this to work. I was trying to run the function against the new order i created instead of going back to the database to get the line items. The part I missed was that the line items aren't stored in the order object I create.

So I'm set. Thanks.
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

©2024 Develisys. All rights reserved.
  • Toll-free  888-665-8637
  • International  +1 717-220-0012