Scripting

Expand all | Collapse all

I'm curious if this is possible or if I'm headed d

  • 1.  I'm curious if this is possible or if I'm headed d

    Posted 12-18-2018 07:02
    I'm curious if this is possible or if I'm headed down a dead end: Is it possible to have a post-read script affect the grid properties? A client requested a script in SO Entry that will turn the Item Code cell different colors depending on their warehouse quantities. I wrote this and it works great as the user is entering a sales order. However, if they click off the lines tab and then go back all the colors are gone. Same goes for if they save it and go back to the order at a later moment. So I added a script that loops through the lines on table-post read and it tells me that it set the color for the lines but it actually doesn't. If you guys think it should work I'll keep tweaking but I'd love that confirmation before I lose a week of my life to this thing. Thank you!


  • 2.  RE: I'm curious if this is possible or if I'm headed d

    Posted 12-18-2018 07:11
    I've only been able to reliably script whole column colours... not individual cells based on line data. If successful I'd be interested in knowing it's possible too!


  • 3.  RE: I'm curious if this is possible or if I'm headed d

    Posted 12-18-2018 07:19
    I am pretty sure I have done this in the post-load of the lines tab and the post-read of the detail object. Also, instead of just the item code cell, why not do the whole row?


  • 4.  RE: I'm curious if this is possible or if I'm headed d

    Posted 12-18-2018 07:27
    @DavidSpeckII I would love the color of the whole row to change, in everything I could find you had to call each cell and changing just one was sufficient, but if you have something for the whole row then...jackpot! I have a script that loops through the lines on post-read of the detail object and according to the debug it is executing successfully but no colors actually change. I will move it to postload and see if that makes a difference. I'd be way interested to see how you have done it before or I'm happy to post mine and you might see something I have that is incorrect.


  • 5.  RE: I'm curious if this is possible or if I'm headed d

    Posted 12-18-2018 07:49
    I'll post example later today.


  • 6.  RE: I'm curious if this is possible or if I'm headed d

    Posted 12-18-2018 07:54
    Now that I think of it, I did do rows once. I'll have to rack my brain to find the script though. (I believe it is something like column 0 = whole row).


  • 7.  RE: I'm curious if this is possible or if I'm headed d

    Posted 12-18-2018 08:06
    You are correct Kevin. Setting the Grid control's column or row property to 0 allows you to change all columns or all rows. Off the top of my head without an example, in a UI post-load, you should be able to use ``` oUIObj.SetControlProperty ""GD_Lines"", ""Column"", 0 oUIObj.SetControlProperty ""GD_Lines"", ""Row"", <current line in your loop> oUIObj.SetControlProperty ""GD_Lines"", ""BackColor$"", ""Light Red"" ``` I'll add that before I set properties like these, i first get them and store in a variable so I can revert it back to what it was once I am done.


  • 8.  RE: I'm curious if this is possible or if I'm headed d

    Posted 12-18-2018 08:18
    There is a tip in this SC post if you want to fine tune your colours... https://sagecity.na.sage.com/support_communities/sage100_erp/f/sage-100-personalization-customization-and-productivity-tools/99908/ouiobj-setcontrolproperty-question?ReplySortBy=CreatedDate&ReplySortOrder=Ascending


  • 9.  RE: I'm curious if this is possible or if I'm headed d

    Posted 12-18-2018 15:18
    I'm getting a type mismatch on oUIObj, even though I have this line: Set oUIObj = oSession.AsObject(oScript.UIObj) is that line different when doing panel postload?


  • 10.  RE: I'm curious if this is possible or if I'm headed d

    Posted 12-18-2018 21:48
      |   view attached
    You can do this with two (one for the post-load event and one for the table events) scripts or one script using the following. The following will work if you create a single script file and attach it to the detail's post-read/post-validate and the library's lines and linesw post-load events. It will handle the different references between the object handles passed into it from the BOI. You can see in the attached image how it worked. I have the following attached to the detail post-read, detail item code post-validate (v2018), and lines post-load. ``` If oScript.UIObj > 0 Then nRowInLoop = 0 nOldRow = 0 : oSession.AsObject(oScript.UIObj).GetControlProperty ""GD_Lines"", ""Row"", nOldRow nOldCurrentRow = 0 : oSession.AsObject(oScript.UIObj).GetControlProperty ""GD_Lines"", ""CurrentRow"", nOldCurrentRow nOldColumn = 0 : oSession.AsObject(oScript.UIObj).GetControlProperty ""GD_Lines"", ""Column"", nOldColumn nOldCurrentColumn = 0 : oSession.AsObject(oScript.UIObj).GetControlProperty ""GD_Lines"", ""CurrentColumn"", nOldCurrentColumn Set oLinesObj = oBusObj If InStr(UCase(oScript.GetCurrentProcedure()), ""POSTLOAD"") > 0 Then Set oLinesObj = oSession.AsObject(oBusObj.Lines) oSession.AsObject(oLinesObj.ScriptObject).DeactivateProcedure ""*ALL*"" sCurrentLineKey = """" : oLinesObj.GetValue ""LineKey$"", sLineKey sCurrentEditKey = """" : sCurrentEditKey = oLinesObj.GetEditKey(sCurrentLineKey) oLinesObj.MoveFirst nRowInLoop = 1 Else nRowInLoop = CInt(nOldRow) End If bLinesProcessed = False Do Until bLinesProcessed bRowMeetsCriteria = False sCriteria = """" sItemCode = """" : oLinesObj.GetValue ""ItemCode$"", sItemCode If sItemCode = ""ARS-9101"" Then bRowMeetsCriteria = True oScript.DebugPrint ""bRowMeetsCriteria: "" & bRowMeetsCriteria If bRowMeetsCriteria Then oSession.AsObject(oScript.UIObj).SetControlProperty ""GD_Lines"", ""Row"", nRowInLoop oSession.AsObject(oScript.UIObj).SetControlProperty ""GD_Lines"", ""Column"", 0 oSession.AsObject(oScript.UIObj).SetControlProperty ""GD_Lines"", ""BackColor$"", ""Light Red"" oSession.AsObject(oScript.UIObj).SetControlProperty ""GD_Lines"", ""Row"", nOldRow oSession.AsObject(oScript.UIObj).SetControlProperty ""GD_Lines"", ""CurrentRow"", nOldCurrentRow oSession.AsObject(oScript.UIObj).SetControlProperty ""GD_Lines"", ""Column"", nOldColumn oSession.AsObject(oScript.UIObj).SetControlProperty ""GD_Lines"", ""CurrentColumn"", nOldCurrentColumn End If If InStr(UCase(oScript.GetCurrentProcedure()), ""POSTLOAD"") > 0 Then nRowInLoop = nRowInLoop + 1 oLinesObj.MoveNext bLinesProcessed = CBool(oLinesObj.EoF) Else bLinesProcessed = True End If Loop If InStr(UCase(oScript.GetCurrentProcedure()), ""POSTLOAD"") > 0 Then oLinesObj.EditLine sCurrentEditKey oSession.AsObject(oLinesObj.ScriptObject).ActivateProcedure ""*ALL*"" End If Set oLinesObj = Nothing End If ```


  • 11.  RE: I'm curious if this is possible or if I'm headed d

    Posted 12-20-2018 07:20
    Thank you so much @DavidSpeckII this is awesome and I really appreciate your willingness to help out!