Changing a date field on a new line with an unrelated Pre-Write script also changes that date's format - confuses customer

I discovered that if a date field (e.g. PromiseDate or ExpirationDate) is changed on a new SO or PO line with a Pre-Write event that also sets any other value in that line, the screen format of the changed date for that line also automatically changes from m/d/yyyy to YYYYMMDD after the line is finished and until the order is saved and reopened.

The underlying data is unaffected.

Sample Pre-Write script:

retVal = oBusObj.SetValue("COMMENTTEXT$", "This is a test")

Demonstration:

Steps to recreated:

  1. Open a new or existing sales order
  2. Drag a date field onto the main grid (e.g.PromiseDate or ExpirationDate)
  3. start a new line
  4. before leaving the line change a date field
  5. move off the line with a tab key, enter key or mouse click

Environments affected:

Sage 100 2016 - 2020
Standard,Advanced and Premium

  • 0

    Working As Designed.  Been that way for a long time. Talked about this is a session on Custom Office at the Sage Summit once. Bring it up with Steve or Elliott

  • 0

    You need to call the UI object's FormatRow method but it requires a numeric handle to the grid and a numeric value for the row number. In a column level validation event, it is safe to use the CurrentRow property of the primary grid but in a pre-write event, it gets tricky because the CurrentRow property is changed to the destination row before the pre-write fires so you may need a post read script to set the current row into a storage variable of the detail's script object.

    Here is a sample if this was a column level or button script.

    If oScript.UIObj > 0 Then
    	Set oUIObject = oSession.AsObject(oScript.UIObj)
    	oUIObject.InvokeChange "PromiseDate$", "20201228", "GD_Lines"
    	nGD_Lines_Ctl = 0 : oUIObject.GetControlProperty "GD_Lines", "Ctl", nGD_Lines_Ctl : If IsNumeric(nGD_Lines_Ctl) Then nGD_Lines_Ctl = CLng(nGD_Lines_Ctl) Else nGD_Lines_Ctl = 0
    	nGD_Lines_CurrentRow = 0 : oUIObject.GetControlProperty "GD_Lines", "CurrentRow", nGD_Lines_CurrentRow : If IsNumeric(nGD_Lines_CurrentRow) Then nGD_Lines_CurrentRow = CLng(nGD_Lines_CurrentRow) Else nGD_Lines_CurrentRow = 0
    	If nGD_Lines_Ctl <> 0 And nGD_Lines_CurrentRow > 0 Then 
    		oUIObject.ShowRow nGD_Lines_Ctl, nGD_Lines_CurrentRow
    		oUIObject.FormatRow nGD_Lines_Ctl, nGD_Lines_CurrentRow
    	End If
    	Set oUIObject = Nothing
    End If

  • 0 in reply to David Speck

    So as i expected, the pre-write event behaves differently, only way i could get the desired results was with the following.

    If oScript.UIObj > 0 Then
    	Set oUIObject = oSession.AsObject(oScript.UIObj)
    	oBusObj.SetValue "CommentText$", "Test"
    	oUIObject.SetVar "CMD_STR$", "X _obj'FormatRow(GD_Lines.Ctl, cChangedRow)"
    	Set oUIObject = Nothing
    End If