PO Detail History SetKeyValue not working

SOLVED

Not sure how to word this, but I'm trying to pull some values from PO_PurchaseOrderHistoryInqDetail_bus. The script runs with no errors (button script), but no data is returned. I have a working script that pulls from SO_SalesOrderHistoryInquiryDetail_bus, so I'm sure it's something stupid that I'm just not seeing. Here are the two scripts:

The PO script that doesn't work:

Set oPOCpy = oSession.AsObject(oSession.GetObject("PO_PurchaseOrderHistoryInqDetail_bus"))
retVal = oPOCpy.SetKeyValue("PurchaseOrderNo$",srcOrdNum)
retVal = oPOCpy.SetKeyValue("SequenceNo$",sLineNum)
retVal = oPOCpy.Find()

retVal = oPOCpy.GetValue("ItemCode$",srcItemCode)
retVal = oPOCpy.GetValue("ItemType$",srcItemType)
retVal = oPOCpy.GetValue("ItemCodeDesc$",srcDescription)
retVal = oPOCpy.GetValue("ExtendedDescriptionKey$",srcExtDescKey)

The SO script that DOES work:

Set oSOCpy = oSession.AsObject(oSession.GetObject("SO_SalesOrderHistoryInquiryDetail_bus"))
retVal = oSOCpy.SetKeyValue("SalesOrderNo$",srcOrdNum)
retVal = oSOCpy.SetKeyValue("SequenceNo$",sLineNum)
retVal = oSOCpy.Find()

retVal = oSOCpy.GetValue("ItemCode$",srcItemCode)
retVal = oSOCpy.GetValue("ItemType$",srcItemType)
retVal = oSOCpy.GetValue("ItemCodeDesc$",srcDescription)
retVal = oSOCpy.GetValue("ExtendedDescriptionKey$",srcExtDescKey)

Any ideas on what I'm missing?

  • 0

    Also, for the PO script that doesn't work, "oPOCpy.LastErrorMsg" says "Purchase Order Number is read only."

  • +1
    verified answer

    This business object works differently, similar to AR_InvoiceHistoryInquiryDetail_bus. One way to deal with it is start at the header object and SetFilter to the lines with the header key, then do your Find. Something like this:


    Set oPOCpy = oSession.AsObject(oSession.GetObject("PO_PurchaseOrderHistoryInq_bus"))
    Set oPOCpyLines = oPOCpy.AsObject(oPOCpy.Lines)

    retVal = oPOCpy.Find(srcOrdNum)
    retVal = oPOCpyLines.SetFilter("", oPOCpy.GetKey())
    FoundLine = oPOCpyLines.Find(srcOrdNum & sLineNum)

    If FoundLine Then

    retVal = oPOCpyLines.GetValue("ItemCode$",srcItemCode)
    retVal = oPOCpyLines.GetValue("ItemType$",srcItemType)
    retVal = oPOCpyLines.GetValue("ItemCodeDesc$",srcDescription)
    retVal = oPOCpyLines.GetValue("ExtendedDescriptionKey$",srcExtDescKey)

    sMsg = "srcItemCode = " & srcItemCode & vbCrLf & _
    "srcItemType = " & srcItemType & vbCrLf & _
    "srcDescription = " & srcDescription & vbCrLf & _
    "srcExtDescKey = " & srcExtDescKey

    Else

    sMsg = "Line not found. Last error = " & oPOCpyLines.LastErrorMsg

    End If
    retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)

  • 0 in reply to Alnoor

    Alnoor,

    Thank you so much! That worked perfectly.