Adding in tracking numbers
-
- Lieutenant Commander (LCDR)
- Posts: 98
- Joined: Fri Apr 29, 2011 2:56 pm
Adding in tracking numbers
I started a project months ago to integrate NetSuite and AC7, and I'm finally at a point to try and finish it. In getting to the finalization, my clients decided that they would like to have tracking numbers imported in as well as having the order staus updated. The problem I'm running into is trying to add the tracking numbers to an order. NetSuite's web services returns all the order's tracking numbers in form of a string, but trying to understand how to add these tracking numbers has left me befuddled. Now there is the possibility each order will have more than one tracking number and they won't al necessarily be for the same shipping company (as in there may be tracking numbers for both FedEx Ground and UPS Frieght). Could someone point me to some sample code in C# for adding the tracking numbers?
Re: Adding in tracking numbers
You can look Admin\Orders\Batch\Ship.aspx.cs and see this code:
You can get the shipment ID for each product in an order form the ac_OrderItems.OrderShipmentID field. The ShipGatewayId comes from the ac_ShipGateways table.
Each order can have multiple shipments per order and it looks like you can multiple tracking number per order shipment. See the ac_TrackingNumbers table. The order page doesn't let you add more than one tracking number per shipment, but it does display multiple tracking numbers. The MyOrder.aspx page also displays multiple tracking numbers.
Hope that helps!
Code: Select all
TrackingNumber tn = new TrackingNumber();
tn.OrderShipmentId = shipmentId;
tn.ShipGatewayId = AlwaysConvert.ToInt(ddl.SelectedValue);
tn.TrackingNumberData = tb.Text;
shipment.TrackingNumbers.Add(tn);
shipment.TrackingNumbers.Save();
Each order can have multiple shipments per order and it looks like you can multiple tracking number per order shipment. See the ac_TrackingNumbers table. The order page doesn't let you add more than one tracking number per shipment, but it does display multiple tracking numbers. The MyOrder.aspx page also displays multiple tracking numbers.
Hope that helps!
-
- Lieutenant Commander (LCDR)
- Posts: 98
- Joined: Fri Apr 29, 2011 2:56 pm
Re: Adding in tracking numbers
Thank you, that does help point me in the right direction. However, all this code is being placed in a separate dll file and is not being directly attached to any page, so I don't have any page fields to draw data from, as this bit is meant to be a scheduled task that runs in the background (attached to a custom page that will be refreshed periodically on a local server). Every piece of information has to be able to be pulled from the order object that gets loaded.
-
- Lieutenant Commander (LCDR)
- Posts: 98
- Joined: Fri Apr 29, 2011 2:56 pm
Re: Adding in tracking numbers
I'm thinking maybe create a shipment dynamically for each tracking number returned from NetSuite. Do the shipment IDs restart at 1 or 0 for each order?
Re: Adding in tracking numbers
The OrderShipmentID is an INT IDENTITY field so it is always incrementing.
If you create a new ac_OrderShipments record you've got a lot of data to fill in (address, shipping method, etc) and then associate the OrderShipment record with some number of products in the ac_OrderItems records. You can see how this works in the Admin\Orders\Shipments\AddShipment.ascx.cs file. Instead of pulling from the input fields you'll be getting your data from NetSuite.
If you know the OrderID and the ProductID or SKU, you can get the OrderShipmentID from the ac_OrderItems tables. With that info you can create Tracking Number records using the code above, just use your tracking number string instead of tb.text. If you need to break up the shipments to represent which products are going with each tracking number you'll need to create new OrderShipment records like the AddShipment page does.
If you create a new ac_OrderShipments record you've got a lot of data to fill in (address, shipping method, etc) and then associate the OrderShipment record with some number of products in the ac_OrderItems records. You can see how this works in the Admin\Orders\Shipments\AddShipment.ascx.cs file. Instead of pulling from the input fields you'll be getting your data from NetSuite.
If you know the OrderID and the ProductID or SKU, you can get the OrderShipmentID from the ac_OrderItems tables. With that info you can create Tracking Number records using the code above, just use your tracking number string instead of tb.text. If you need to break up the shipments to represent which products are going with each tracking number you'll need to create new OrderShipment records like the AddShipment page does.
-
- Lieutenant Commander (LCDR)
- Posts: 98
- Joined: Fri Apr 29, 2011 2:56 pm
Re: Adding in tracking numbers
I had to put this project back down for a little while, but getting back to it, I found I have another question.
The order in question will be getting its record loaded in order to both save new data to it and to retrieve any needed data from it. Would it be correct to assume that at least one OrderShipment object should already be attached to the order record? If so, then I plan to just add the tracking numbers to any existing OrderShipment objects. But if I have to create a new OrderShipment object, how do I go about determining what the ShipmentId should be?
The order in question will be getting its record loaded in order to both save new data to it and to retrieve any needed data from it. Would it be correct to assume that at least one OrderShipment object should already be attached to the order record? If so, then I plan to just add the tracking numbers to any existing OrderShipment objects. But if I have to create a new OrderShipment object, how do I go about determining what the ShipmentId should be?
Re: Adding in tracking numbers
vashts1980,
Did you find the answer to your question? We've been doing some work loading tracking numbers and trying to find the correct shipment for the tracking number.
1. Yes, there should be an OrderShipment record/object already created for each order.
2. You can assign the tracking number and shipping gateway to the "first" OrderShipment record and it will show up properly in the user's order page.
Did you find the answer to your question? We've been doing some work loading tracking numbers and trying to find the correct shipment for the tracking number.
1. Yes, there should be an OrderShipment record/object already created for each order.
2. You can assign the tracking number and shipping gateway to the "first" OrderShipment record and it will show up properly in the user's order page.