Shipment Header Information

While I can connect to SQL to extract the data directly, how might I go about using the API to extract Scaffold Tag Shipment Header information for a specific Project?

Ultimately, I would like to create an extract listing:

CUSTOMER NUMBER
CUSTOMER NAME
JOB NUMBER
JOB NAME
TAG NUMBER
TAG ORDER NUMBER
SHIPMENT NUMBER
SHIPMENT DATE
ACTUAL BUILD DATE
ACTUAL DISMANTLE DATE
TYPE OF SHIPMENT (Delivery or Return)
SHIPMENT TOTAL WEIGHT
SHIPMENT TOTAL PEICES

Any and all help certainly would be appreciated.

Hi James. Connecting directly to the database will nullify your support contract. We’ve written the API for this very reason (and others). Do you want the sample code in VB or C#?

Would very much appreciate the code in VB.

Thank you.

The key to this is to fetch the job (or, surround all of this code with loop through a list of jobs), all related scaffolds (or one) for each job, and then all related shipments to/from the scaffold. This is a few nested loops.

The thing to note is that when shipments are shipped to/from a scaffold, they’re shipped to an underlying hidden RelatedStockingLocation (which is another reason to not hit the database, you’ll never find it).

' Get job. The example here uses the name "tags"
Dim job As StockingLocation = StockingLocation.GetStockingLocation("tags", False)

' Get list of scaffolds for the job
Dim tags As ScaffoldTagCollection = ScaffoldTagCollection.GetScaffoldTagCollection(job.StockingLocationID, False)

For Each tag As ScaffoldTag In tags

    ' Get shipments for the tag, which are to/from an invisible related stocking location
    Dim shipments As ShipmentList = ShipmentList.GetShipmentList(tag.RelatedStockingLocation.StockingLocationID)

    For Each shipment As ShipmentListItem In shipments

        ' Info from the parent job
        Debug.Print(job.CustomerName)
        ' customer number, name, number, etc.

        ' Info from scaffold
        Debug.Print(tag.Tag)
        ' build date, dismantle date, etc

        ' Info from shipment. You'll need to decide what to do with
        ' transfers
        If shipment.ShipmentType = ShipmentType.Delivery Then
            Debug.Print("Delivery")
        ElseIf shipment.ShipmentType = ShipmentType.Return
            Debug.Print("Return")
        ElseIf shipment.ShipmentType = ShipmentType.Transfer
            Debug.Print("Transfer")
        End If
        Debug.Print(shipment.TotalProducts.ToString())
        Debug.Print(shipment.TotalWeight.ToString())

    Next
Next

How would I use this same code, but pass the Job Number instead of the Job Name?

Dim job As StockingLocation = StockingLocation.GetStockingLocation(???, False)

There’s a StockingLocation.GetStockingLocation() that takes a name. Intellisense should show you which one it is, there’s boolean to not prefetch the child locations which you can set to False.

I tried this which is still not returning Tags even though I am 100% sure that the variable str_Job_Number being passed is a valid job number., which does have tags assigned. Ideas?

Public Function Extract_QA_Detailed_Data_for_Tag_Shipments(str_Job_Number As String) As Boolean

    Dim result As Boolean = True

    Try

        AvontusPrincipal.Logout()

        Dim success As Boolean = AvontusPrincipal.Login(HIDDEN, HIDDEN)

        If success = False Then

            result = False

        Else

             Dim job As StockingLocation = StockingLocation.GetStockingLocation(str_Job_Number, False)

            ' Get list of scaffolds for the job
            Dim tags As ScaffoldTagCollection = ScaffoldTagCollection.GetScaffoldTagCollection(job.StockingLocationID, False)

            For Each tag As ScaffoldTag In tags

Additionally, I tried the code passing my Job name and the output is not providing me the Weight or Pieces, although this information is clearly visible within Quantify.

A-02
Delivery
0
0

A-01
Delivery
0
0

A-01
Return
0
0

alternately you can try and fetch the job using the parent trading partner, then load the stocking location from that.

    ' Load TradingPartner
    Dim tp As TradingPartner = TradingPartner.GetTradingPartner("JobName")
    ' Load job
    Dim job As StockingLocation = StockingLocation.GetStockingLocation(tp.StockingLocationID, False, False)

Weight and pieces are on the shipment products

ship.ShipmentProducts.TotalWeight
ship.ShipmentProducts.TotalPieces

Okay, I am getting lost…

The first code provided works 100% except:

  1. I want to use a Job Number instead of a Job Name to get the shipment information.
  2. The Pieces and Weight are coming in at zero for each shipment.

Based on these requirements, what changes to the code originally provided would need to be incorporated?

The first overload on StockingLocation.GetStockingLocation will take a number or an accounting ID, you can try and experiment with that. Can you post your code for weight and pieces under a separate thread with sample code?

If I use this

Dim job As StockingLocation = StockingLocation.GetStockingLocation("213001")

No Tag are found.

If I use this

Dim job As StockingLocation = StockingLocation.GetStockingLocation("Job 213001", False)

Tags are found but I want the User to provide the Job Number.

This is my code currently that worsk except for the pieces and weight:

            Dim job As StockingLocation = StockingLocation.GetStockingLocation("Job 213001", False)

            ' Get list of scaffolds for the job

            Dim tags As ScaffoldTagCollection = ScaffoldTagCollection.GetScaffoldTagCollection(job.StockingLocationID, True)

            For Each tag As ScaffoldTag In tags

                ' Get shipments for the tag, which are to/from an invisible related stocking location

                Dim shipments As ShipmentList = ShipmentList.GetShipmentList(tag.RelatedStockingLocation.StockingLocationID)

                For Each shipment As ShipmentListItem In shipments

                    ' Info from the parent job

                    Debug.Print(job.CustomerName)

                    ' customer number, name, number, etc.

                    ' Info from scaffold
                    Debug.Print(tag.Tag)

                    ' build date, dismantle date, etc
                    Debug.Print(tag.ActualBuildDate)
                    Debug.Print(tag.ActualDismantleDate)
                    Debug.Print(tag.Notes)

                    ' Info from shipment. You'll need to decide what to do with
                    ' transfers

                    If shipment.ShipmentType = ShipmentType.Delivery Then
                        Debug.Print("Delivery")
                    ElseIf shipment.ShipmentType = ShipmentType.Return
                        Debug.Print("Return")
                    ElseIf shipment.ShipmentType = ShipmentType.Transfer
                        Debug.Print("Transfer")
                    End If

                    Debug.Print(shipment.TotalProducts.ToString())
                    Debug.Print(shipment.TotalWeight.ToString())

                Next

            Next

This is my output, which is not pulling the Customer, the Tag dates, and not pulling the Shipment pieces and weight.

A-0002

Erection of scaffold for access to Valve 5302
Delivery
0
0

A-0003

Erection of scaffold for access to Valve 5303
Delivery
0
0

A-0001

Erection of scaffold for access to Valve 5301
Delivery
0
0

You’ll probably need to continue to use the name if the number isn’t working. Load the shipment instead of a ShipmentListItem and the quantities and weight will work.

Please provide code regarding ‘Load the shipment instead of a ShipmentListItem’. Sorry, but I still are trying to decipher the API.

To get the shipment, inside your For Each shipment … Loop:

    ' Load shipment
    Dim ship As Shipment = Shipment.GetShipment(shipment.ShipmentID, False, False, False)

Sorry but still having issues… I pasted the code in the loop as suggested…

 For Each shipment As ShipmentListItem In shipments

                    Dim ship As Shipment = shipment.GetShipment(shipment.ShipmentID, False, False, False)

In IDE, I get message that GetShipment is not a member of ShipmentListItem.

Also, not that this should be the issue, but this is a job falling beneath a staging area. Does that matter?

It’s a VB.NET issue. Rename the ‘shipment’ in the loop to something else, like shipList.

I am finally able to achieve “most” of what I am after. Thank you very, very much!

            Dim job As StockingLocation = StockingLocation.GetStockingLocation("Job 213001", False)

            ' Get list of scaffolds for the job

            Dim tags As ScaffoldTagCollection = ScaffoldTagCollection.GetScaffoldTagCollection(job.StockingLocationID, True)

            For Each tag As ScaffoldTag In tags

                ' Get shipments for the tag, which are to/from an invisible related stocking location

                Dim shipments As ShipmentList = ShipmentList.GetShipmentList(tag.RelatedStockingLocation.StockingLocationID)

                For Each individual_shipment As ShipmentListItem In shipments

                    Dim ship As Shipment = Shipment.GetShipment(individual_shipment.ShipmentID, False, False, False)

                    ' Info from scaffold
                    Debug.Print(tag.Tag)
                    Debug.Print(tag.OrderNumber)
                    Debug.Print(tag.Notes)
                    Debug.Print(tag.PriorityName)
                    Debug.Print(ship.ShipmentNumber)
                    Debug.Print(ship.ActualShipDate)
                    Debug.Print(ship.TotalPieces)
                    Debug.Print(ship.TotalWeight)

                Next

            Next