AR Invoice Data Entry Copy From Functionality

Has anyone ever retrieved values from the AR_InvoiceHistory Header & Detail tables from inside a vb script?

At the end of the day I am trying to duplicate the logic behind the "Copy From" button on the sales order header screen so that when a user creates a new invoice in AR Invoice Data Entry, the user can enter a previous invoice number in a textbox, click on a button, and all values from  the historical invoice will copy into the new invoice.

error_code = 0
invoice_number = "12827E"
invoice_type = ""
confirm_to = ""

SET oS = oSession.AsObject(oSession.GetObject("AR_Invoice_svc"))

retval = oS.SetKeyValue("InvoiceNumber$", invoice_number)
retval = oS.SetKeyValue("HeaderSeqNo$", "000000")
retval = oS.Find()

error_code = oS.GetValue("UDF_TYPE$", invoice_type)
error_code = oS.GetValue("ConfirmTo$", confirm_to)

msgbox(invoice_type)
msgbox(confirm_to)

The results of the two message boxes were blank values, and I know the data exists in the historical invoice for those fields.

I have also tries using the following with the same results:

SET oS = oSession.AsObject(oSession.GetObject("AR_InvoiceHistoryInquiry_svc"))

Any ideas? I think a stored procedure approach is a really bad idea when it comes to the lines screen mainly because of efficiency.

Parents Reply Children
  • 0 in reply to BigLouie

    Thanks for the reply BL.

    Is his Posted By name "kanes"? There a lot of Steves that show up lol

  • 0 in reply to it_q-lab

    I meant Steve Malmgren, Chief Architect of Sage MAS 90 and 200.  Here is the link. No sure if they still work.

    sagecity.na.sage.com/.../102910.aspx

  • 0 in reply to BigLouie

    Hi ,

    The history object that you would need to use is the AR_InvoiceHistoryInquiry_bus this will have a handle to the detail lines as well called .Detail_Object.  Unfortunately, you need to use the business objects to get to the line details.  So, you'd need to change your script slightly...

    error_code = 0

    invoice_number = "12827E"

    invoice_type = ""

    confirm_to = ""

    SET oS = oSession.AsObject(oSession.GetObject("AR_InvoiceHistoryInquiry_bus"))

    retval = oS.SetKeyValue("InvoiceNumber$", invoice_number)

    retval = oS.SetKeyValue("HeaderSeqNo$", "000000")

    retval = oS.SetKey()  ' should check for retVal=1 here as any other value will indicate that the record does not exists

    error_code = oS.GetValue("UDF_TYPE$", invoice_type)

    error_code = oS.GetValue("ConfirmTo$", confirm_to)

    msgbox(invoice_type)

    msgbox(confirm_to)

    Give that a try.  Hope it helps you get started. 

    Elliott