Full GL Account from SO line script (CostOfGoodsSoldAcctKey / SalesAcctKey)

SOLVED

I'm starting a script for account segment substitution (CoGS / Sales accounts on specific SO lines), and before I start testing different methods for getting the formatted Account number based on the key values (ChildHandle, open a new object...) I'm wondering if there is a shortcut to go directly there?

For the "SetValue" I can pass in a formatted account number using this:

retVal = oBusObj.SetValue("AccountKey$", sNewAccount,"kACCOUNT")

Is there an equivalent "GetValue" I can use... like this?  (Guessing at the syntax... does not work):

retVal = oBusObj.GetValue("CostOfGoodsSoldAcctKey$", sCOGSAccount,"kACCOUNT")
retVal = oBusObj.GetValue("SalesAcctKey$", sSalesAccount,"kACCOUNT")

I remember problems testing previous scripts using GetChildHandle with GL accounts, and I'd prefer not to require access to GL_Account_svc for the script to function.

Parents
  • 0
    SUGGESTED

    How about this for retrieving the formatted account numbers in SO lines:

    sCostOfGoodsSoldAcctKey = "":retVal = oUIObj.GetValue("ML_CostOfGoodsSoldAcctKey",sCostOfGoodsSoldAcctKey)
    sSalesAcctKey = "":          retVal = oUIObj.GetValue("ML_SalesAcctKey",sSalesAcctKey)
    retVal = oSession.AsObject(oSession.UI).MessageBox("","sSalesAcctKey=" & sSalesAcctKey & "; sCostOfGoodsSoldAcctKey=" & sCostOfGoodsSoldAcctKey)

  • +1 in reply to connex
    verified answer

    I would think that would only work if your script is only executing on the currently selected line, however, if you are looping through lines than it would not work.

    Here is a list of "data sources" that you can use GetChildHandle on from the sales order Lines object.

    MAIN
    ItemCode
    UnitOfMeasure
    SalesAcctKey
    CostOfGoodsSoldAcctKey
    TaxClass
    CommodityCode
    WarehouseCode
    WarrantyCode
    BillOption1
    BillOption2
    BillOption3
    BillOption4
    BillOption5
    BillOption6
    BillOption7
    BillOption8
    BillOption9
    ItemDescription
    APDivisionNo
    VendorNo

    So you should be able to use the following.

    oBusObj.ReadAdditional "SalesAcctKey"
    sSalesAcctKey = "" : oSession.AsObject(oBusObj.GetChildHandle("SalesAcctKey")).GetValue "Account$", sSalesAcctKey
    oBusObj.ReadAdditional "CostOfGoodsSoldAcctKey"
    sCostOfGoodsSoldAcctKey = "" : oSession.AsObject(oBusObj.GetChildHandle("CostOfGoodsSoldAcctKey")).GetValue "Account$", sCostOfGoodsSoldAcctKey

Reply
  • +1 in reply to connex
    verified answer

    I would think that would only work if your script is only executing on the currently selected line, however, if you are looping through lines than it would not work.

    Here is a list of "data sources" that you can use GetChildHandle on from the sales order Lines object.

    MAIN
    ItemCode
    UnitOfMeasure
    SalesAcctKey
    CostOfGoodsSoldAcctKey
    TaxClass
    CommodityCode
    WarehouseCode
    WarrantyCode
    BillOption1
    BillOption2
    BillOption3
    BillOption4
    BillOption5
    BillOption6
    BillOption7
    BillOption8
    BillOption9
    ItemDescription
    APDivisionNo
    VendorNo

    So you should be able to use the following.

    oBusObj.ReadAdditional "SalesAcctKey"
    sSalesAcctKey = "" : oSession.AsObject(oBusObj.GetChildHandle("SalesAcctKey")).GetValue "Account$", sSalesAcctKey
    oBusObj.ReadAdditional "CostOfGoodsSoldAcctKey"
    sCostOfGoodsSoldAcctKey = "" : oSession.AsObject(oBusObj.GetChildHandle("CostOfGoodsSoldAcctKey")).GetValue "Account$", sCostOfGoodsSoldAcctKey

Children
  • 0 in reply to David Speck

    Thanks David.  That is what I was thinking of trying first, but remember (years ago) having intermittent issues in a similar script where the wrong Account's information was returned... however I'm fairly certain I wasn't using ReadAdditional back then, so maybe that will make things work smoothly.