Sage 100

 View Only
  • 1.  Hide Column on Sales Order Panel

    Posted 05-05-2020 09:30
    Team,

    I am trying to write a script that will hide the unit price and extension columns on the Sales Order Panel based on the user roles.

    The following is my custom office script (w/o role piece yet) which is a postload on the plines panel of SO_SalesOrder.m4l

    gridCtl = "" gridCtl = ""
    retVal = oUIObj.GetControlProperty("GD_Lines", "Ctl", gridCtl)

    ' hide the price column
    retVal = oUIObj.HideColumn(CInt(gridCtl), "UnitPrice")
    retVal = oUIObj.HideColumn(CInt(gridCtl), "ExtensionAmt"

    I can make it work as a button that you click on and the 2 columns hide; however, the post-load script is not hiding the columns as soon as the panel is open. 

    The option to hide the columns in customize based on user group will not work at this client. 

    Any thoughts or suggestions on how I can hide the unit price column based on roles would be greatly appreciated.
    I am running Sage 100c Standard v2019 p2

    Thank you
    Michael

    ------------------------------
    Michael Davis
    Warren Averett Technology Group
    Birmingham, AL
    ------------------------------


  • 2.  RE: Hide Column on Sales Order Panel

    Posted 05-06-2020 12:54
    Did you syntax check your script?
    You are missing the closing parenthesis on the second HideColumn.
    For what it's worth, if i'm not expecting to check the returned value of a method in VBScript, i just skip the "retVal = " and opening and closing parenthesis since VBScript will complain otherwise under certain conditions.
    Also, i use CLng for object handles and controls instead of CInt.
    Keep in mind that using HideColumn will hide the column from view and keep a user from being able to tab into it but if they right click and click "Show Column", the user will be able to show the column again if they are ware of this.

    ------------------------------
    David Speck II
    Tennessee Software Solutions
    ------------------------------



  • 3.  RE: Hide Column on Sales Order Panel

    Posted 05-06-2020 13:33
    ​David,

    Thank you the suggestion. The closing parenthesis was there, I just missed it on the copy and paste.

    I am not as familiar with CLng. Would the syntax be 
    retVal =oUIObj.HideColumn(CLng(gridCtl), "ExtensionAmt")

    If so, the script is not automatically hiding the column on the load panel script.

    Good point about the right click and show column. Just trying to figure any method to prevent the viewing of the unit price and extension amount based on roles.

    Thank you
    Michael

    ------------------------------
    Michael Davis
    Warren Averett Technology Group
    Birmingham, AL
    ------------------------------



  • 4.  RE: Hide Column on Sales Order Panel

    Posted 05-06-2020 15:27
    Have you confirmed the target columns are in the main grid? HideColumn won't work if they are in the secondary grid.
    CLng is a VBScript function just like CInt except it converts to the Long data type instead of Integer.
    Also, in your post example, you have the gridCtl = "" repeated twice on the same line, this should fail the syntax check and cause the script to fail silently.
    If you are not sure whether or not your script is getting to a certain point in the script, add either of the following lines. 
    ' Write to the trace window.
    oScript.DebugPrint "Reached this point." 
    
    
    
    ' Display a sage 100 message box.
    oSession.AsObject(oSession.UI).MessageBox "", "Reached this point."

    In order to enable the trace window, follow these instructions.

    retVal = oScript.DebugPrint(text)

    Method to output variables and text to aid in debugging scripts.  This requires use of the Providex trace window.  This trace window can be enabled by adding 'Debug=1' in the SOTA.ini file in the Launcher directory under the [config] section.  Once enabled right click on the Sage 100 title bar of the current task (e.g. AR Customer Maintenance) and select Debugging Environment..Program..Trace Window.  In the trace window choose Options..Suppress Program trace.  When the scripts are running, any text from a DebugPrint() call will be displayed in the trace window.



    ------------------------------
    David Speck II
    Tennessee Software Solutions
    ------------------------------