Sage 100

 View Only
  • 1.  Detail SetValue/InvokeChange causing discrepancies in the grid's row on version 2018 .2 Advanced with JobOps

    Posted 04-01-2019 13:22
    I've encountered an issue on version 2018.2 Advanced with JobOps and a post read event script on SO_SalesOrderDetail.

    I am attempting to set a value on the post read event in a column of the current row but for some reason, in this install, SetValue is behaving like InvokeChange and causing discrepancies in what is displayed in the grid's rows.

    On past versions, i was able to get around this with either SetValue, Write, then reload the grid or first set the grid control's Row and CurrentRow and then call InvokeChange. 

    On this install, no matter what i do with the grid's Row, CurrentRow properties or the local cRow, cCurrentRow, cOldRow, cLastRow, cGridRow[], etc properties prior to the SetValue/InvokeChange, it always causes the last row with focus to mirror the line receiving focus.

    At the moment, i have managed to use a UI post load script to append the XEQ function calling my logic to the cGridRowMods$[] logic and the _FCS_TBL$[] logic which i am able to make the change in there but would prefer to avoid this if i can.

    Has anyone else been able to get around this issue with any other creative solutions?


    #BOI #script #scripting #Sage100​​​​

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


  • 2.  RE: Detail SetValue/InvokeChange causing discrepancies in the grid's row on version 2018 .2 Advanced with JobOps

    Posted 04-03-2019 02:35
    Edited by Alnoor Cassim 04-03-2019 02:50
    JobOps overrides SO_SalesOrderDetail_bus and SO_CommonEntryDetail to do "special" things to support their functionality. This means even with mods (non-scripting) on JobOps systems, we don't necessarily get the expected behavior. Let's leave it at that.

    Let me ask simpler question of what are you trying to accomplish with the SetValue on PostRead anyway? If changing say Unit Price, maybe you can move that to PreWrite or PostVal of ItemCode ?? Let's pretend you are doing SetValue on UnitPrice. Do you need any normal dict or other validation to fire off OR your own separate PostVal script to fire off when you set UnitPrice? If not, does SetValueNoValidate do the trick?

    Let's say it works but doesn't refresh the ExtensionAmt. Then try your normal trick of Write'ing the line then reloading the grid then positioning yourself on the same row (while not recursively firing off your PostRead) but here is something else to look into.

    When MDs / DPs change developer fields on lines and don't want to have to reload the whole grid, they take advantage of what happens in standard code when you change the Qty Ordered. Have you ever wondered why when you change the Qty, the ExtensionAmt refreshes yet w/o a full reload of the grid? 

    Trace it then look at how ChangeQuantityOrdered() in SO_CommonEntry_UI runs, how it runs ShowRow() and how it runs TranslateColumns(). I've never tried it with script.

    To recap: 
    1. Knowing you can't control JobOps induced stuff, can you use PreWrite or PostVal of ItemCode instead?
    2. Do you need any normal validation or new script firing off on the col being set? If not, can you do SetValueNoValidate()  instead?
    3. If SetValueNoValidate() works except for grid cells not refreshing, use one of the two ways to refresh.
    Hope that helps.

    ------------------------------
    Alnoor Cassim

    Free Agent Developer and Consultant
    CallForHelp.biz
    Email: alnoor@callforhelp.biz
    Orange County, CA
    ------------------------------



  • 3.  RE: Detail SetValue/InvokeChange causing discrepancies in the grid's row on version 2018 .2 Advanced with JobOps

    Posted 04-05-2019 08:37
    Thanks Alnoor, you got me going in the right direction, although i didn't have any luck with TranslateColumns actually making a difference, it didn't cause an error. I did get ShowRow to give me tease of it working but when stepping off the line to a new line or going to a different tab and back, the row wasn't saving regardless of the method used to set the value (SetValue, SetValueNoValidate, InvokeChange, MainGridCtl'Value$)

    ShowRow works great if i don't actually want to save the value and just use the column as a place holder to display data retrieved but for this purpose, i do want the value saved. 

    After a bunch of tracing and watching values, I eventually found the missing link causing all of this grid corruption, it seems sage 100 doesn't call the ClassOnFocusGrid() method before or during the first table script PostRead event and because of this, it throws off some protected variables causing them to lag a row behind. The end result is SetValue and InvokeChange thinking focus is still on the previously selected row.

    Using the following code, i can consistently set the value and the header will recognize that the line was changed. InvokeChange would work in place of SetValue but for the target column this will be used for, the column will be locked and InvokeChange doesn't play nicely with locked columns so i'm just using SetValue, end result appears to be the same.

    Dim sItemCode
    Dim oBusObj_UI
    Dim nGD_Lines_Ctl
    Dim nGD_Lines_RowsHigh
    Dim nGD_Lines_CurrentRow
    Dim sCurrentKey
    sItemCode = "" : oBusObj.GetValue "ItemCode$", sItemCode
    If sItemCode <> "" And oBusObj.EditState = 1 Then
    	If oScript.UIObj > 0 Then 
    		Set oBusObj_UI = oSession.AsObject(oScript.UIObj)
    		nGD_Lines_Ctl = 0 : oBusObj_UI.GetControlProperty "GD_Lines", "Ctl", nGD_Lines_Ctl : nGD_Lines_Ctl = CLng(nGD_Lines_Ctl)
    		If nGD_Lines_Ctl > 0 Then 
    			nGD_Lines_RowsHigh = 0 : oBusObj_UI.GetControlProperty "GD_Lines", "RowsHigh", nGD_Lines_RowsHigh : nGD_Lines_RowsHigh = CLng(nGD_Lines_RowsHigh)
    			If nGD_Lines_RowsHigh > 0 Then
    				oScript.DeactivateProcedure "PostRead"
    				oBusObj_UI.ClassOnFocusGrid nGD_Lines_Ctl
    				nGD_Lines_CurrentRow = 0 : oBusObj_UI.GetControlProperty "GD_Lines", "CurrentRow", nGD_Lines_CurrentRow : nGD_Lines_CurrentRow = CLng(nGD_Lines_CurrentRow)
    				If nGD_Lines_CurrentRow > 0 Then
    					sCurrentKey = "" : sCurrentKey = oBusObj.GetKeyPadded()
    					oBusObj.SetValue "CommentText$", "Testing"
    					oBusObj.Write
    					oBusObj.EditLine sCurrentKey
    				End If
    				oScript.ActivateProcedure "PostRead"
    			End If
    		End If
    	Else
    		oBusObj.SetValue "CommentText$", "Testing"
    	End If
    End If
    ​


    I found that i could also use oBusObj_UI.SaveRow and oBusObj_UI.GetLineRecord instead of oBusObj.Write and oBusObj.EditLine but the results appeared to be the same. I just needed to make sure after the writing/saving of the line/row, the line/row was put back into edit mode so it didn't cause a disconnect between the grid and ui and the line object.

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