Scripting

  • 1.  Script for deleting Sales Order zero order-qty li

    Posted 01-10-2018 10:45
    Script for deleting Sales Order zero order-qty lines - retval = 1 on all calls. linesval (delete call) returns 1 also, but the delete doesn't happen. Is this a data-file vs. memory-table issue? Invoked from Sales Order Header Table pre-totals linesval =0 olines = 0 orderqty = 0 orderno = """" linekey = """" set olines = oBusObj.AsObject(oBusObj.Lines) ' get lines handle linesVal = oLines.MoveFirst() retVal = oSession.AsObject(oSession.UI).MessageBox("""", ""after moveFirst, retval= "" & cstr(linesval)) RETURNS 1 Do Until CBool(oLines.EOF) retVal = oLines.GetValue(""QuantityOrdered"", orderqty) retVal = oLines.GetValue(""SalesOrderNo$"", orderno) retVal = oLines.GetValue(""Linekey$"", linekey) retVal = oSession.AsObject(oSession.UI).MessageBox("""", ""order,line and qty are: ="" & orderno & "" "" & linekey & "" "" & cstr(orderqty)) RETURNS ORDER, LINEKEY and OrderQuantity values Correctly If orderqty = 0 then linesval = oLines.deleteline(orderno & linekey) retVal = oSession.AsObject(oSession.UI).MessageBox("""", ""after deleteline, retval= "" & cstr(linesval)) RETURNS linesval = 1 End If retVal = oLines.MoveNext() Loop


  • 2.  RE: Script for deleting Sales Order zero order-qty li

    Posted 01-10-2018 11:20
    It's still all memory channels. So it's easier to do oLines.Delete() and be done with it otherwise you have to do something like this: EditKey = oLines.GetEditKey(LineKey) oLines.DeleteLine(EditKey) I believe because we're using KDISPLAY as the main index (not KPRIMARY) your delete line key is really OrderNo + LineSeqNo + LineKey. DeleteLine would probably work on that too.


  • 3.  RE: Script for deleting Sales Order zero order-qty li

    Posted 01-10-2018 13:01
    Thanks Alnoor - olines.Delete() took care of it.