Shipment Header Information

Glad to help, great that it’s working.

Can you please advise how I can extract the Customer Name given this routine?

I have attempted the below and it is given a “”"" result.

job.CustomerName

Thank you.

Can someone please advise how I achieve getting the Customer Name for a Job, Job Number, or StockingLocationID)?

The code above works. You’re probably not fetching the job. The line directly after you fetch the job, check that the name or number are what you expect, and not a blank string. If it’s a blank string then it wasn’t loaded.

The code works, well sort of…

I have two jobs with tags beneath them, if I pass one job number, I am able to get the associated tag shipments for the job, just not the Customer Name from the job object. If I pass the other job number, no tag shipments are returned although I can see the exist in Quantify.

is there a possible attribute somewhere causing one job number to pull in the data successfully (although customer name on the job object is still blank) while the other will not?

If there’s no customer name or tags, shipments, etc., on the job object then it’s not being loaded properly. You’ll want to review the code that’s loading the job.

I am using the code I posted previously. As mentioned, if I send the Job Name, it works correctly, however, if I send the Job Number, it works for one of my jobs but not the other.

Looking for other options. Any help is greatly appreciated.

You can use this chunk of code to determine if the job is loaded correctly. In addition to checking the name, you can also check the ID of the object. If neither are the same after you’ve loaded it then it wasn’t successfully loaded. We don’t throw an exception here for performance reasons.

Dim jobName as String = "My Job Name"
Dim job As StockingLocation = StockingLocation.GetStockingLocation() // pass in ID, etc
If job.Name = jobName Then
    Console.WriteLine("Job loaded")
Else
    Console.WriteLine("Job not loaded")
End If

I’m finally back…

I am using this code the extract the basic tag header information:

Dim job As StockingLocation = StockingLocation.GetStockingLocation("ERGON JOB", 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
' Info from the parent job

Debug.Print("Customer:" + job.CustomerName)

' customer number, name, number, etc.

' Info from scaffold
Debug.Print("Tag:" + tag.Tag)

' build date, dismantle date, etc
Debug.Print("Build:" + tag.ActualBuildDate)
Debug.Print("Dismantle:" + tag.ActualDismantleDate)
Debug.Print("Notes:" + tag.Notes)

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

If ship.ShipmentType = ShipmentType.Delivery Then
Debug.Print("Type:" + "Delivery")
ElseIf ship.ShipmentType = ShipmentType.Return Then
Debug.Print("Type:" + "Return")
ElseIf ship.ShipmentType = ShipmentType.Transfer Then
Debug.Print("Type:" + "Transfer")
End If

Debug.Print("Weight:" + ship.TotalWeight.ToString())
Debug.Print("****************************************")

Next

Now, can someone advise what I need to connect to so that I may extract the Products for a Shipment?

Thank you.

Hi James. The products are contained in the ship.ShipmentProducts collection that’s found on the shipment that you’ve loaded.

Okay, things are working now… thank you for your continued assistance.

Three things:

  1. ContextSwitchDeadlock keeps occurring in Visual Studio 2015 running the below code. Any advice?

  2. For a Scaffold, is there a way to add Voided as a Status item?

  3. Can you please review the following code and advise why (and suggestion of how) the CustomerName is not populating from job.CustomerName? In the following code, the information is blank.

    Dim str_Job As String
    Dim str_Customer As String
    Dim str_Tag_Number As String
    Dim str_Order_Number As String
    Dim str_Shipment_Number As String
    Dim str_Start_Date As String
    Dim str_Stop_Date As String
    Dim str_Notes As String
    Dim str_Shipment_Type As String
    Dim str_Shipment_Weight As String

    Dim str_Item_Number As String
    Dim str_Item_Description As String
    Dim str_Item_Quantity As String
    Dim str_Item_Rate As String
    Dim str_Item_Weight As String

    Dim job As StockingLocation = StockingLocation.GetStockingLocation(“ERGON JOB”, False)

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

    For Each tag As ScaffoldTag In tags

     If tag.ScaffoldTagStatusText <> "Completed" Then
    
         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)
             
             str_Job = job.Number & "-" + job.Name
             str_Customer = job.CustomerName
             str_Tag_Number = tag.Tag
             str_Order_Number = tag.OrderNumber
             str_Shipment_Number = ship.ShipmentNumber
             str_Start_Date = tag.ActualBuildDate
             str_Stop_Date = tag.ActualDismantleDate
             str_Notes = tag.Notes
             
             If ship.ShipmentType = ShipmentType.Delivery Then
                 str_Shipment_Type = "Delivery"
             ElseIf ship.ShipmentType = ShipmentType.Return Then
                 str_Shipment_Type = "Return"
             ElseIf ship.ShipmentType = ShipmentType.Transfer Then
                 str_Shipment_Type = "Transfer"
             End If
             
             str_Shipment_Weight = ship.TotalWeight.ToString
             
             For Each individual_item As ShipmentProduct In ship.ShipmentProducts
             
                 str_Item_Number = individual_item.PartNumber
                 str_Item_Description = individual_item.Description
                 str_Item_Quantity = individual_item.ActualOriginal.ToString
                 str_Item_Rate = individual_item.RentRate.ToString
                 str_Item_Weight = individual_item.Weight.ToString
    
             Next
    
         Next
    
     End If
    

    Next

Hello James. Sorry, not sure about Visual Studio. I ran your code and it seems to work fine without any contextswitchdeadlock.

Yes, you can add/change the name for scaffold statuses in global options.

Looks like we have a little bug in our API on the customer name. You can use this code to get it instead

Dim customer As BusinessPartner = BusinessPartner.GetBusinessPartner(job.BusinessPartnerID)
str_Customer = customer.Name

Thank you for your reply.

The contextswitchdeadlock issue is resolved. It was a setting in Vb I had to turn off.

I am unable to find any place under the Global Options where I can administer the Scaffold Statuses.

The alternative to pulling the Customer Name for the Job works.

As the API portion of my issue is resolved, can you advise if I should continue on the scaffold status issue here or someplace else?

Glad you got the issue resolved. Scaffold Statuses are in Global Options - Shipments and Scaffolds tab, then the Scaffold sub-tab. Depending on the edition of Quantify that you have they’re editable here, I believe it’s industrial edition.

Me again…

In this snippet

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

      If job.Name = str_Job_Name Then

           Dim customer As BusinessPartner = BusinessPartner.GetBusinessPartner(job.BusinessPartnerID)

           Debug.Print(System.DateTime.Now)
           
           Dim tags As ScaffoldTagCollection = ScaffoldTagCollection.GetScaffoldTagCollection(job.StockingLocationID, True)

           Debug.Print(System.DateTime.Now)

the

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

action takes approximately 1 minute before the tags are returned. In my database, the passed Job is the ONLY job using Tags, and with a total of only 66 tags, is this time to be expected?

Hi James. Yes, when using a collection that’s very normal. There are lots of rules that need to be loaded and checked as you can modify any of the objects within and save the collection.

If you’re just looking up data then you’ll want to use the ScaffoldTagList instead. Even then, sometimes it’s faster to use the List, then load a single tag and save it separately if needed.

Can you elaborate a bit more on ScaffoldTagList?

I am needing to extract tag header details, tag shipments, and tag shipment items. This is more of my code…

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

                For Each tag As ScaffoldTag In tags

                    If tag.ScaffoldTagStatusText <> "Completed" Then

                        gid_ScaffoldTagID = tag.ScaffoldTagID

                        str_Job = job.Number & "-" + job.Name

                        str_Customer = customer.Name

                        str_Tag_Number = tag.Tag

                        str_Order_Number = tag.OrderNumber

My code works with using the collection, it just add an extra minute to the process.

Can you advise how I can achieve the same using the ScaffioldTagList option?

Hi James. Just replace this line:

Dim tags As ScaffoldTagList = ScaffoldTagList.GetScaffoldTagList(…)
For Each tag As ScaffoldTagListItem in tags

This should load several thousand times faster than the collection. Would definitely be worth it to refactor. Most of the properties are exactly the same.

ScaffoldTagList.GetScaffoldTagList(…) is expecting a list(of GUID) parameter…

Is there a manner in implementing where I can just pass a single job.StockingLocationID like I am able to do with the ScaffoldTagCollection.GetScaffoldTagCollection?

Yes, you simply create a new list and add your guid to it:

Dim locations as List(Of Guid) = New List(Of Guid)
locations.Add(yourGuid)