Copy invoice from AR_InvoiceHistory to flat file

SUGGESTED

I have most of this script working but am hung up on the part reading from the line detail object.  I have created a button on the AR Invoice History Inquiry panel so that the end user can find the invoice they want to copy, press the button, and the flat file will be generated.  This part of the script works fine (getting the header variables):

if oSession.UI<>0 Then

    Set oUI = oSession.AsObject (oSession.UI)

End If

retVal = oBusObj.GetValue ("InvoiceNo$", invoice_number)

retVal = oBusObj.GetValue ("InvoiceDate$", invoice_date)

retVal = oBusObj.GetValue ("CustomerNo$", customer_number)

And so on.........  But, when I try to get the line detail, here is my script:

Set oLines = oBusObj.AsObject (oBusObj.Lines)

retVal = oLines.MoveFirst()

Do until oLines.EOF

    retVal = oLines.GetValue ("DetailSeqNo$", line_number)

    retVal = oLines.GetValue ("ItemCode$", item_code)

The script fails at the Set oLines = oBusObj.AsObject (oBusObj.Lines), saying "Wrong number of arguments or invalid property assignment: 'oBusObj.Lines'

Evidently, that fails to open the detail object but I don't know the syntax to do it correctly.

Any help?

Parents Reply Children
  • 0 in reply to Kevin M

    Well I AM only trying to read the detail lines. 

    I've been able to read SO_InvoiceHeader and SO_InvoiceDetail data using similar logic, but I can't seem to get this to work at all for AR_Invoice_History

  • 0 in reply to Byron

    I did a quick test and the same thing happened to me.  I don't have an answer. 

    In a rush I'd try AR_InvoiceHistoryInquiryDetail_bus (with browse filter) or ODBC... but maybe someone else has better suggestions.

  • 0 in reply to Byron

    Okay, I have found the solution and am posting it here for anyone else with the same problem:

    oLines = oSession.GetObject ("AR_InvoiceHistoryInquiryDetail_bus")

    if oLines <> 0 then

        Set oLines = oSession.AsObject (oLines)

    End If

    The trick was getting the correct object name, AR_InvoiceHistoryInquiryDetail_bus

  • 0 in reply to Byron
    SUGGESTED

    Be sure to set a browse filter.  That is done automatically when created from the oSession object, but has to be done manually when creating a new object.

  • 0 in reply to Kevin M

    A little late but certain inquiry tasks do not actually have a Lines property like their entry tasks do which is why you get the error trying to reference that property.  

    So getting your own handle works but as Kevin said, you need to set the browse filter yourself, which you should be able to use the header's oBusObj.GetKeyPadded() method plus the CHR function for the NULL character (0).  Whenever you use the browse filter functionality with mutli-part keys, all but the last segment needs to be NULL padded.  If all of your invoice numbers are 7 characters long, this in't an issue but should you have some where the invoice number is less than 7 (the max length for the invoice number field) characters, then your browse filter will fail.