Update Purchase Order line UDF during receipt of goods entry

I am trying to update a UDF in Purchase Order entry lines during a receipt of goods.  The issue I am having is that the purchase order record is locked while a receipt of goods / invoice records exist referencing the purchase order.    Here is the code I am using below.  I do not receive an error, but the PO line is not update.   Any direction would be greatly appreciated.

editline = ""
editline = oPOLines.GETEDITKEY(lineno)
retval = oPOlines.editline(editline)

if retval = 1 then
    poitem = ""
    retVal = oPOLines.GetValue("ItemCode$",poitem)
    retVal = oPOLines.GetValue("UDF_QTY_INTRANSIT",intranqty)
    intran = intranqty - QtyReceived

    retVal = oPOLines.SetValue("UDF_QTY_INTRANSIT",intran)
    retVal = oPOLines.SetValue("CommentText$","Justin was here")
    retVal = oPOLines.Write()

    if retval = 0 then
        oui.messagebox(opolines.LastErrorMsg)
    end if

else
    oui.messagebox(opolines.LastErrorMsg)
end if

I have also tried calling the child object, but not sure how to determine which child objects are available.  Here is the code I have tried, but do not find the child object:

polineobj = 0
opolineobj = oROGLines.GetChildHandle("OrderLineKey")  ' opollineobj = 0

if opolineobj <> 0 then  '
    Set opolineobj = oSession.AsObject(opolineobj)
else
    oui.messagebox("No opolineobj object")
End if

  • 0

    PO Receipts update uses the PO busines object to update puchase orders.  You can check the oSession'Updating property to know that a PO is being updated by receipt update.

    For example:

    PO_PurchaseOrderDetail - PreWrite event:

    retval = 0

    qtyReceived = 0

    qtyTransit = 0

    if oSession.Updating then

         retval = oBusObj.GetValue("UDF_QTY_TRANSIT", qtyTransit)

         retval = oBusObj.GetValue("QuantityReceived", qtyReceived)

         qtyTransit = qtyTransit - qtyReceived

         retval = oBusObj.SetValue("UDF_QTY_TRANSIT", qtyTransit)

    end if