Script access to SO_PackageTrackingByItem from SO_InvoiceDetail script

SOLVED

I need to access values in a UDF added to Item Packaging Maintenance (Shipping Data Entry), from a header or detail script, but I can't figure out how to open that object.

Trying the command Window to list methods / properties for the Lines object from Shipping data entry, I can't see anything that would take me to the Package contents.  (Distribution is for tier quantities, not package quantities).

The header object has a method for CheckItemPackageQuantity (which won't work since I need access to package UDF data), but nothing that I could see for accessing the package contents directly.

I'd assume it is something like this...

set oPackage = oSession.AsObject(oHeaderObj.Package)

...but that is just a wild guess that doesn't work.

I know I'll need a loop (since the primary key on SO_PackageTrackingByItem doesn't link from an invoice linekey...) which I am fine with, but I need access to the data first. 

Opening a new object to SO_PackageTrackingByItem_bus won't work because I need access to unsaved data entry.

TIA for any assistance.

  • +1
    verified answer

    Hi  

    There doesn't seem to be any public references to that object in the header/detail business classes, however, I don't think that's necessary.  I believe this information is committed physically to the files when you "Accept" from the Item Package Maintenance dialogue.  So, if you create a new shipment, and access the item package window, make changes and press Accept.  If you look through DFDM you'll notice that information is actually stored even though your invoice is not committed yet.  Not sure why we did it that way.

    So that being said you should be able to use SO_PackageTrackingByItem_svc/bus classes to access that data within your script, but you'll have to instantiate a new instance of that object.

    Key reference is InvoiceNo + PackageNo + ItemCode

    Hope this helps, let me know if you need more assistance.

    Elliott

  • 0 in reply to jepritch

    Thanks Elliott!  Interesting... I was just assuming the package data would be uncommitted until the invoice was saved.

    That could work.  (New object, browse filter, loop through the packages for what I need... then close the object).

    The shipments are created by import / integration (ScanForce) and I need the UDF data for another integration (StarShip) so I'm hoping that the BOI object behavior works the same as the UI in that way.  I'm guessing PreTotals is the best place to try and do what I need...

    I'll post results when I get a chance to do some testing.

  • 0 in reply to Kevin M

    So far so good... basic testing with the UI gave me access to package data (...but thinking as I type this, I was testing with a pre-saved invoice)... and I'll find out soon about whether it solves the problem...

    ...

        oPackage = oSession.GetObject("SO_PackageTrackingByItem_bus")
        if oPackage <> 0 then
            Set oPackage = oSession.AsObject(oPackage)
        else    
            if oSession.UI <> 0 then
                retVal = oSession.AsObject(oSession.UI).MessageBox("", "Access to SO_PackageTrackingByItem_bus is required for the ... script to work.")
            end if
            exit sub
        end if
        retVal = oPackage.SetBrowseFilter(sInvoiceNo)
        retVal = oPackage.MoveFirst()
        if retVal <> 1 then ' no package data for this invoice, do nothing
            Set oPackage = nothing
            exit sub
        end if

    ...

    Thanks again Elliott