Type mismatch: 'CopyFromOrder' (err/ret=2/0)

SOLVED

Is my syntax wrong here? I'm trying to launch this script when a checkbox is checked on SO Entry (after generating a new order #), but I'm getting an error. Perhaps I'm just not using the function properly. I'm receiving an error stating: Type mismatch: 'CopyFromOrder' (err/ret=2/0)

Here is my code:


'retval = CopyFromOrder(order$, type$, clearJob, copyMemos) 'this is from the object reference
retval = 0

retval = CopyFromOrder("0000001", "Q", 0, 0) '0000001 being the order I want to copy from

Parents
  • 0
    SUGGESTED

    Thank you, everyone.  Got the bones of this in working order.  I still have work to do, but here is the code in case anyone is searching the forums in the future.

    'to be triggered on column post validate of UDF_GenerateBO in Invoice Data Entry
    'Creates a copy of the order being invoiced

    'retval = CopyFromOrder(order$, type$, clearJob, copyMemos)


    retval = 0
    sSO = ""
    sNewSO = ""

    retval = oBusObj.GetValue("SalesOrderNo$", sSO)

    oSO = oSession.GetObject("SO_SalesOrder_Bus")

    sNewSO = "B" & right(sSO,6)

    retVal = oSession.AsObject(oSession.UI).MessageBox("SO No: " & sSO & vbcrlf & "New SO: " & sNewSO)

    if oSO <> 0 then

    set oSO = oSession.AsObject(oSO)

    'retval = oSO.CopyFromOrderHistory(sSO, "S", 0, 0)

    'retval = oSO.GetNextSalesOrderNo(sNewSO)

    retval = oSO.SetKey(sNewSO)
    if retval = 0 then
    retVal = oSession.AsObject(oSession.UI).MessageBox("*" & oSO.LastErrorMsg)
    end if

    retval = oSO.CopyFromOrder(sSO, "S", 0, 0)
    if retval = 0 then
    retVal = oSession.AsObject(oSession.UI).MessageBox("*" & oSO.LastErrorMsg)
    end if


    retVal = oSO.Write()
    if retval = 0 then
    retVal = oSession.AsObject(oSession.UI).MessageBox("*" & oSO.LastErrorMsg)
    end if

    end if

  • 0 in reply to n0tgunshy2

    I'm somewhat curious why you wouldn't just let Sage generate the BO automatically as you post the invoice.

Reply Children