Scripting

  • 1.  Hi All -I am working on a script to update SO I

    Posted 07-19-2017 07:15
    Hi All - I am working on a script to update SO Invoice lines with cost code and cost type for a Job Costing project. We are using a button script for this as not all invoices are Job Cost related. The user can click and update cost code/cost types for all the lines when they are in appropriate invoices and wish to do so. The script logic does a loop through all the lines and a retval =olines.write at the end of each line loop. This appears to work fine and updates the lines as expected, however the grid does not refresh until going to the totals tab or main tab etc. I searched around and looked in my class materials, but was unable to find an example of a button script that refreshes the grid. I found a write up about hiding a button on the main tab and then having the script 'click' it at the end of the script. I also saw things about InvokeChange and linesadded=-1. What is the best way to refresh the grid? Anyone have a tried and true snippet for refreshing the grid after updating the lines? thank you, Marc


  • 2.  RE: Hi All -I am working on a script to update SO I

    Posted 07-19-2017 07:27
    see if the below works for you. ___________________________________________________ If IsObject(oUIObj) Then If Left(UCase(oUIObj.GetFolderName()), 6) = ""PLINES"" And True Then sMapId = """" sCtlName = ""GD_Lines"" nGridCtl = 0 : nGridCtl = oUIObj.GetControlID(""GD_Lines"", sMapId, sCtlName) oUIObj.ClearGrid(nGridCtl) oUIObj.ClearTotals() nRetval = oUIObj.LoadLines(nGridCtl) End If End If ___________________________________________________


  • 3.  RE: Hi All -I am working on a script to update SO I

    Posted 07-19-2017 07:41
    I hope that David's code works since the HandleUI refreshes have never worked consistently for me. I usually cheat and kick the user to another panel so that they can click back on Lines and see the updated grid. I'm not proud of that, but clients begrudgingly accepted it...


  • 4.  RE: Hi All -I am working on a script to update SO I

    Posted 07-19-2017 07:48
    i'll add that this should work fine since you are running from a button script and the UI object that should be available is the SO_SalesOrder_UI which has the methods needed for this. I believe the common way to do this via scripting is to use the following but i've have experienced inconsistent results as well. The oScript.LoadGrid method populates the oScript.GridToLoad property. Then when the script finishes, if oScript.LinesAdded is not 0, it should trigger the UI object to call the last 3 methods in my first post. _______________________ oScript.LoadGrid(""GD_Lines"") oScript.LinesAdded = -1 _______________________


  • 5.  RE: Hi All -I am working on a script to update SO I

    Posted 07-19-2017 12:22
    Thank you @DavidSpeckII - I used the If isObject(oUIOBJ) then . . . . routine after the loop through all the lines and now when i click the button it fills in the cost type cost codes and then refreshes the grid. Works EXCELLENT so far. Some more testing to do but looks promising. Thanks again I appreciate it!! @SteveIwanowski I agree on the click to totals then back again being a little bit clunky - this is what they were doing but didnt like that they had to 'trust' that it updated and were always going back to the lines to double check. Lucky for us this is a button script this time so it is working. thanks for the replies guys!