Scripting

  • 1.  Hi all - I am working with a button script in Sa

    Posted 08-06-2015 07:59
    Hi all - I am working with a button script in Sales Order that will remove zero quantity lines from an order. The script is assigned to a button on the plines screen that a user would click if they wanted to remove the zero lines from a template order. It functions as planned except after deleting zero lines, the grid doesn't refresh until I click a different tab and return to the lines tab. What is the best way to refresh a grid after you've removed lines? Or am I forgetting something here with my deletion? Here is what I have so far: 'Title:Button Script - place on SO details tab, will remove any line where order qty + bo qty = 0 '***** 'Desc: Remove SO detail lines where Order Qty+ BO Qty = 0 '***** 'Bus Object: Button Script '***** 'Event: Assign to button on UI '***** 'Revision History 'Written by Marc C of Technology Integrators 8.6.2015 '***** 'start on header then run through details retVal = oScript.DebugPrint(""**Start Script RemoveZeroSOLinesButtonScript.txt***"") sItemCode = """" sItemType = """" sLineSeqNo = """" nLinesRemoved = 0 nQtyOrd = 0 nQtyBO = 0 Set oLines = oSession.AsObject(oBusObj.Lines) retVal = oLines.movefirst() 'goto top line of details 'now loop through detail lines of order do until cBool(oLines.EOF) 'first make sure line type is an item not misc chg/comment retval = olines.getvalue(""ItemType$"",sItemType) 'get item type retval = olines.getvalue(""ItemCode$"",sItemCode) 'get item code retval = olines.getvalue(""QuantityOrdered"",nQtyOrd) 'get quantity ordered retval = olines.setvalue(""QuantityBackordered"",nQtyBO) 'get quantity Backordered retVal = oScript.DebugPrint(""Item Type is "" & sItemType) retVal = oScript.DebugPrint(""Item Detail found "" & sItemCode) retVal = oScript.DebugPrint(""Qty Ordered + QtyBO = "" & nQtyOrd+nQtyBO) if sItemType = ""1"" then 'if this is an item code line then check for quantities if nQtyOrd + nQtyBo = 0 then 'if the sum of ordered + backordered = 0 then delete the line retVal = oScript.DebugPrint(""Delete-able line found!"") retval=olines.delete() nLinesRemoved = NLinesRemoved + 1 'add to removed counter end if end if retval = olines.movenext() loop retVal = oScript.DebugPrint(nLinesRemoved & "" Lines Deleted from SO."") retVal = oScript.DebugPrint(""**End Script RemoveZeroSOLinesButtonScript.txt***"")


  • 2.  RE: Hi all - I am working with a button script in Sa

    Posted 08-06-2015 08:05
    This is what I have from the best professor in the world (@AlnoorCassim ) 'Refresh grid to show changes oScript.LinesAdded = 1 oScript.LoadGrid(""GD_Lines"") I've used it several times and it works to refresh the grid without clicking anything.


  • 3.  RE: Hi all - I am working with a button script in Sa

    Posted 08-06-2015 08:13
    This worked perfectly! Thank you so much for your help!