Quantify connection for BI Tool

I have some strange loop while going up the hierarchy. Each job is being listed at each branch.
Here that section of code.
’ Get list of jobs
Dim jobs As StockingLocationList =
StockingLocationList.GetJobsites(False, JobTreeNodeDisplayType.Name, Guid.Empty)

    ' Loop through jobs and write name to console window
    For Each job As StockingLocationListItem In jobs
        ' Get the stocked products for the branch
        ' Get list of scaffolds for the job
        Dim tags As ScaffoldTagCollection = ScaffoldTagCollection.GetScaffoldTagCollection(job.StockingLocationID, False)
        For Each tag As ScaffoldTag In tags
        Next

        'Get immediate parent Branch or Laydown Yard
        Dim branches As StockingLocationList =
        StockingLocationList.GetBranchOfficesAndLaydownYards(False, Guid.Empty)


        ' Loop through the branches
        For Each branch As StockingLocationListItem In branches



            Dim TradPart = TradingPartner.GetTradingPartner(branch.ParentTradingPartnerID)
            Dim stocks As StockedProductList =
            StockedProductList.GetStockedProductList(job.StockingLocationID,
            Guid.Empty, ProductType.Product)
            ' Parent above tradpart
            Dim firstAbove As TradingPartner = TradingPartner.GetTradingPartner(TradPart.ParentTradingPartnerID)

            Dim secondAbove As TradingPartner = TradingPartner.GetTradingPartner(firstAbove.ParentTradingPartnerID)

            If firstAbove.ParentTradingPartnerID <> Guid.Empty Then
                ' Dim secondAbove As TradingPartner = TradingPartner.GetTradingPartner(firstAbove.ParentTradingPartnerID)
            End If
            For Each stock As StockedProductListItem In stocks
                Dim scaf As ScaffoldTagListItem = ScaffoldTagListItem.GetScaffoldTagListItem(branch.TradingPartnerID)

I am working on a deadline on this project. Can someone please reply this morning so I can meet our deadline of EOB today? I have a few other questions like how do I get in transit, on reserve and total available. I am assuming that the onrent object in stock is quantity at job. Can someone contact me directly.

Hi Chris. Sorry you’re having trouble. The code above works for me. You may want to try out the intellisense. After you type “branch” and then “.”, you’ll see a list of properties and methods come up. There you’ll see the various reserved and in transit quantities. If you ‘quick watch’ on the branch, you’ll see the parent properties, and can expand those to see how to traverse up the treeview. Hope this helps.

the problem is that all jobs are being listed at each branch. So a job that should only be for one location is showing up at every location.
Also how do I only get active jobs and branches?

You can also use intellisense to find the ‘IsActive’ property. That is true or false, bound to the same checkbox on the jobsite. Branches are always active.

If you use intellisense on the branch, you’ll see a parent property, which continues to have a parent property recursively until null (Nothing in VB). Once the parent property is null, you’re at the top of the tree.

There is some kind of strange loop. Can someone contact me directly. I know we can get this fixed quickly.
The data is being returned incorrectly. Fro example. I am getting
branch 1, job 1, PN 1
branch 1, job 1, PN 2
branch 2, job 1, PN 1
branch 3 job 1, PN 2
branch 1, job 2, PN 1
branch 2, job 2, PN 1
branch 3, job 2, PN 1

We don’t have developer support contracts. Without looking at your source code and data we have no way of troubleshooting. If you want to send your sample code and a backup of your database in to our support team we can take a look. It will take us a week or so to look at as we’re on the tail end of a release.

Hello Chris. When you send in a backup and a copy of your source code, can you also send through the structure of the data you want output, not just the three columns above? Thanks.

I’ve deleted your last post as it contained login credentials. Have a copy though.

Hi Chris. Can you send all of this via a zip file to https://support.avontus.com/sendfile.html

We need a copy of your Quantify database as well.

All of the files are uploaded.

Hi Chris. After talking with a few people here your looping may be incorrect. First loop through the branches, then within that loop, grab the jobs, and within that loop, grab the tags.

    'Load branches
    branches = ...
    For Each branch In branches
        ' Load jobs for this branch
        jobs = ...
        For Each job In jobs
            ' Load scaffolds for this job (if it's a scaffold job)
            tags = ...
            For Each scaffold In tags
            Next
        Next
    Next

This is what I have so far and it is still returning the information incorrectly. I think it is in the job= or the dim job statement that I am not linking correctly.

   'Get immediate parent Branch or Laydown Yard
    Dim branches As StockingLocationList = StockingLocationList.GetBranchOfficesLaydownYardsAndStagingAreas(False, Guid.Empty)


    ' Loop through the branches
    For Each branch In branches
        ' Dim TradPart = TradingPartner.GetTradingPartner(branch.ParentTradingPartnerID)
        Dim jobs As StockingLocationList = StockingLocationList.GetJobsites(False, JobTreeNodeDisplayType.Name, Guid.Empty)
        ' Loop through jobs and write name to console window
        For Each job In jobs

            Console.WriteLine("Branch: " + branch.Name)
            Console.WriteLine("Type: " + branch.PartnerTypeText)
            Console.WriteLine("job: " + job.Name)

        Next
    Next

Thanks Chris. Will investigate this today.

Hi Chris. Try this code instead. It creates a list of jobs for each branch, then displays that list as the output.

    '  Get all jobs
    Dim jobs As StockingLocationList = StockingLocationList.GetJobsites(False, JobTreeNodeDisplayType.Name, Guid.Empty)
    Dim jobsInBranch As List(Of StockingLocationListItem) = New List(Of StockingLocationListItem)

    ' All branches/staging areas
    Dim branches As StockingLocationList = StockingLocationList.GetBranchOfficesLaydownYardsAndStagingAreas(False, Guid.Empty)

    ' Loop through the branches
    For Each branch In branches

        ' Skip inactive branches
        If branch.IsActive = False Then Continue For

        ' New list for jobs in the branch
        jobsInBranch = New List(Of StockingLocationListItem)

        ' Loop through all jobs
        For Each job In jobs

            ' If ID matches then add to list
            If job.IsActive And job.ParentTradingPartnerID = branch.TradingPartnerID Then
                jobsInBranch.Add(job)
            End If

        Next

        For Each jobInBranch In jobsInBranch
            Console.WriteLine("Branch: " + branch.Name)
            Console.WriteLine("Type: " + branch.PartnerTypeText)
            Console.WriteLine("job: " + jobInBranch.Name)
        Next

    Next

Thanks I will give it a try and let you know. I was looking at the stock in a job and wanted some clarification on the object listed below. What I am trying to get is the Total Qty available, on rent, in transit, in reserve, out of service at the branch and job level.Is the object that i should call or is there another way to get this.

here is the code for stocks that I am using
Dim stocks As StockedProductList =
StockedProductList.GetStockedProductList(job.StockingLocationID,
Guid.Empty, ProductType.Product)
For Each stock In stocks

This will return all of the stocked products at the branch.

        ' Get products stocked at branch
        Dim prods As StockedProductList = StockedProductList.GetStockedProductList(
            branch.StockingLocationID, Guid.Empty, ProductType.Product)

        ' Write stocked parts at branch
        For Each prod As StockedProductListItem In prods
            Console.WriteLine("PN: " + prod.PartNumber)
            Console.WriteLine("Available: " + prod.QuantityForRent)
            Console.WriteLine("Reserved: " + prod.QuantityReserved)
            Console.WriteLine("In Transit: " + prod.QuantityReserved)
        Next

        ' OOS parts for branch or laydown yard
        If branch.PartnerType = PartnerTypes.BranchOffice Or
            branch.PartnerType = PartnerTypes.LaydownYard Then

            ' Get damaged products - Change status for all others
            Dim oosProds As StockedProductExtensionList =
                StockedProductExtensionList.GetStockedProductExtensionList(
                branch.StockingLocationID, StockedProductExtensionCondition.Damaged)

            ' Write stocked parts at branch
            For Each prod As StockedProductExtensionListItem In oosProds
                Console.WriteLine("PN: " + prod.PartNumber)
                Console.WriteLine("Damaged: " + prod.Quantity)
            Next

        End If

And this works for the products on the job. Put this within the jobsInBranch loop.

            Dim jobProds As StockedProductList = StockedProductList.GetStockedProductList(
                jobInBranch.StockingLocationID, Guid.Empty, ProductType.Product)

            For Each prod As StockedProductListItem In jobProds
                Console.WriteLine("PN: " + prod.PartNumber)
                Console.WriteLine("At Job: " + prod.QuantityOnRent)
            Next

So how do I get the total qty available at a branch or staging area.

Sorry I didn’t see the other post where you had that.:slight_smile: