Importing Invoices in BOI doesn't import SO number

SUGGESTED

Hi Forum,

I am importing SO Invoices with a BOI script, imports fine but i cannot get the Sales Order Number to update.

I have 2 scripts, one to import invoices (I cannot set the SO # here, no error just no SO value in the Invoice Header).

the second script imports the Tracking numbers and also works fine except, if I try to update the SO # here i get an error message the i need to set the Batch number and here is the problem.

How can I get the batch number, i know that GL_CompanyActiveBatch table has the Batch numbers but unfortunately there are other users entering invoices manually and there are a few SO Invoice Entry batches.

Here is the code that i am using on the second script:


r = oInv.nSetKeyValue("InvoiceNo$", sInvoice_Num)
r = oInv.nSetKey()
if r = 0 then
MsgBox(oInv.sLastErrorMsg & sInvoice_Num & vbCRLF & "Inv Header Failed")
end if
r = oInv.nSetValue("SalesOrderNo$", strOrderNo)

r = oInv.nWrite()

*** this are the error messages ***

Why i cannot update the sales order when i am importing the Invoices.  I am Importing the order from a text file with all the lines with invoice and SO numbers.

This is the code i use in the invoice import script:

retHdrKey = o.nClear()
msgbox "Last Order: " & sOrdNum
r = oInv.nSetValue("SalesOrderNo$", sOrdNum)

r = oInv.nWrite()

I think i asked this same question time ago but i couldn't find any notes about it.

Regards,

Manuel Roman

Parents Reply Children
  • 0 in reply to David Speck

    I got the batch number issue working but i still cannot update the Sales Order Number in the Invoice Header taable.

    The following is the code that i am using... i get no error at all but it doesn't import the Sales Order Number.

    r = oInv.nSetKeyValue("InvoiceNo$", sInvoice_Num)
    r = oInv.nSetKey()
    if r = 0 then
    MsgBox(oInv.sLastErrorMsg & sInvoice_Num & vbCRLF & "Inv Header Failed")
    end if
    r = oInv.nSetValue("SalesOrderNo$", strOrderNo)


    msgbox "SO #: " & strOrderNo & ", Inv #: " & sInvoice_Num
    r = oInv.nWrite()

    if r = 0 then
    MsgBox(oInv.sLastErrorMsg & strOrderNo & vbCRLF & "SO Header Failed")
    end if

    Reagrds,

  • 0 in reply to mroman

    What is the returned value when setting the value on SalesOrderNo?

    Are you copying the sales order's lines to the invoice before calling the Write method? 

    If not, then you should be checking the LastErrorMsg property, it may be saying the entry has no lines because setting the sales order number alone does not copy the lines, you'll need to use the methods in my last post around copying the lines to the order.

    If still having issues setting the sales order number, then prior to setting the sales order number, I would set the LastErrorMsg property to a blank string, then set the value and check the returned value and the LastErrorMsg property to further narrow this down.

  • 0 in reply to David Speck

    Hi David,

    This is the message that i am getting when setting the Sales Order Number in Invoice Header...

    Is ther a reason why the SO Number cannot be changed?

    Regrads,

  • 0 in reply to mroman

    Is that happening when you are first creating the invoice or when attempting to modify it?  It sounds like the latter and if this is the case, maybe you should use GetValue on SalesOrderNo$ and if it is blank, then use SetValue, otherwise you shouldn't need to set it.