PO Receipt Detail Script to match QtyInv to QtyRec

SOLVED

I'm trying to get the QuantityInvoiced to change to whatever the QuantityReceived is for each line item on Receipt Of Invoice Entry. 

Probably a button script. I have plenty of scripts in place, but I've never written one to cycle through each line. Any tips on how to accomplish this?

Parents
  • 0

    Run from a header event or button script.

    Set oLines = oSession.AsObject(oBusObj.Lines)

    retVal = oLines.MoveFirst()

    do until oLines.EoF

    ' do stuff…

    retVal = oLines.MoveNext()

    loop ' oLines

  • 0 in reply to Kevin M

    Thank you. It doesn't seem to be triggering on any header events though. Might it have something to do with the 'Do you want to invoice the complete purchase order?" message box that comes up on the Lines tab?

    This is my script:

    if oSession.CompanyCode = "MBT" then

    nqtyrec = 0
    nqtyinv = 0
    oLines = 0

    retVal = oBusObj.GetValue("QuantityReceived",nqtyrec)
    retVal = oBusObj.GetValue("QuantityInvoiced",nqtyinv)

    Set oLines = oSession.AsObject(oBusObj.Lines)
    retVal = oLines.MoveFirst()

    do until oLines.EOF

    retVal = oLines.SetValue("QuantityInvoiced", nqtyrec)
    retVal = oLines.Write()
    retVal = oLines.MoveNext()

    loop

    end if

  • +1 in reply to Brown0987
    verified answer

    You're right that the "do you want to..." pop-up question bypasses line events, which is why you need to use a header event or button script.

    Go with the header table PreTotals, which always runs.  Your GetValue needs to be from oLines (not oBusObj), and done inside the loop.

Reply
  • +1 in reply to Brown0987
    verified answer

    You're right that the "do you want to..." pop-up question bypasses line events, which is why you need to use a header event or button script.

    Go with the header table PreTotals, which always runs.  Your GetValue needs to be from oLines (not oBusObj), and done inside the loop.

Children