Sage 100

 View Only
  • 1.  SetControlProperty on GD_Lines for BackColor

    Posted 04-09-2021 16:15
    Hello!
     I am trying to set a color for an entire row based of a field on that row. So when a particular field value is set to "1", I want that row highlighted yellow.
    I have looked through Sage City & seen numerous threads & have tried many methods.
    This is basically my issue:
    Script for overriding AccountKey in JC Job Posting Entry
    Sagecity remove preview
    Script for overriding AccountKey in JC Job Posting Entry
    v2018 (so scripting in JC is possible). I'm writing a script to override the GL account for Job Posting Entry lines. (Detail PreWrite event). I can get the override to work, with a SetValue but the grid does not refresh with the new value. retSet = oBusObj.SetValue("AccountKey$", sNewAccount,"kACCOUNT") When I try to use InvokeChange, nothing happens.
    View this on Sagecity >


    I can get it to work if I manually add a line. The issue is I am using this with Ascent Automated Service invoicing, so it populates numerous lines all at once & once it cycles through the lines, it can't keep the line number separate. 
    This function is on the Lines tab already, so its not like I am selecting a Sales Order on the Header & have the lines populated to fire upon change of panel or loop through them. I tried.
    It seems I have to use a PreWrite on the Details table.
    When I add them manually, I can use the logic for ChangedRow & it works like I need it to.
    When I load all the lines at once, it leaves them all at a value of 0 & doesn't set that row number & fire off correctly.
    If I use CurrentRow, it always sets to the next blank line where my curser ends up.

    I don't get why this is so hard for it to see the row I am on when I write each line. 
    Has anyone successfully been able to set the current row before it moves to the next one? Or know the function to grab this value?

    This is what works manually or if I edit a line previously brought in:
    Event: Table - Pre-Write on SO Invoice Detail

    sHidden = ""
    sLine = ""

    If (oScript.UIObj) Then
    Set oUIObj = oSession.AsObject(oScript.UIObj)
    Else
    sMsg = "No UI"
    retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)
    End If

    curRow = 0
    'retVal = oUIObj.GetControlProperty("GD_LINES", "CurrentRow", curRow)
    retVal = oUIObj.GetValue("cChangedRow", curRow)
    r=oScript.DebugPrint(" CurrentRow = " & curRow)

    retVal = oBusObj.GetValue("D514_HiddenLine$",sHidden)
    r=oScript.DebugPrint(" Hidden Value = " & sHidden)


    If sHidden = "1" then
    retVal = oUIObj.SetControlProperty("GD_LINES","Row", curRow)
    retVal = oUIObj.SetControlProperty("GD_LINES","Column", "0")
    retVal = oUIObj.SetControlProperty("GD_LINES","BackColor","RGB: 255 255 0")

    End If

    #scripting #script #ui ​​​​​

    ------------------------------
    Dana Young
    Lehman Wesley & Associates
    Lansing MI
    ------------------------------


  • 2.  RE: SetControlProperty on GD_Lines for BackColor

    Posted 04-09-2021 17:45
    I checked the grid colour script I have and it's for columns (row 0) not rows, so that won't help your issue... but one thing I see is that it should be "BackColour" not "BackColor".  (In Canada and the UK, we spell colour with the "u").

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 3.  RE: SetControlProperty on GD_Lines for BackColor

    Posted 04-10-2021 21:17
    Edited by David Speck II 04-10-2021 21:32
    Kevin, the ProvideX manual actually states that it accepts both spelling variations for Color and Colour.

    Dana, setting row colors can be tricky because the lines object and the UI object don't really communicate with each other the way you'd expect, the lines object doesn't have any indication of the actual row number that the record appears on in the grid and you can't really use the LineKey or LineSeqNo because the records can be reordered and this causes the LineSeqNo to change and LneKey become invalid for determining row number.

    If you are using a script not attached to the lines, such as on the pLines UI post-load event, then you could loop through all of the lines and by using a variable that you increment to track the row number, you can set the grid's row to the variable value where the record meets your criteria.

    If you are using a script attached to the lines, if it is on anything other than the pre-write and post-write events, then the CurrentRow property of the grid should work when you are navigating/updating lines as a user would.

    One thing you can do is use a simple post-read event script attached to the lines to get the CurrentRow property and then use oScript.SetStorageVar to save it into a variable that you can retrieve in another event script using oScript.GetStorageVar.  These methods tend to convert the data type to a string so after you get the value, you may need to check if it is numeric and then use CLng on it before passing it to the SetControlProperty method.

    I'm not familiar with the enhancement you mentioned so I don't know how and when it is creating the line records so i can't really say what the best approach is without knowing that.

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