In column pre-validate script, compare new value to old (pre-field-edit) value

SOLVED

Writing a script (with role check), where I want to prevent a user from editing a customer's credit limit (ideally preventing a non-admin order entry person, with Customer Maintenance access, from raising a credit limit... without going through an approval process). 

I know "column" and "value" are available, but is there any way to reference the original (pre-edit) value for that column?

For a checkbox it is easy (to freely allow a customer to be put on hold, while preventing a customer from being taken off hold) since if the new value is "Y", you know what the old value was.

For a numeric field I guess a post-read script to SetStorageVar should work (to preload the field value into memory), but I'm wondering if there is something I can do within a single script (besides opening a new service object, finding the customer record, and looking at what that shows)? 

I expect the Sage program has to store the post-load field by field values in memory somehow, but I have no idea how to access those values.

  • +1
    verified answer

    I don't think we have any pre-canned values.  I would recommend doing a .SetStorageVar() in the Post-Read and then in the Pre-Validate of the column fetch that value.  However, if you just want to use a single script you could try the retrieving the value of "cOldVal$", which should  contain the original value of the column.

    origVal = ""

    rVal = oBusObj.GetValue("cOldVal$", origval)

    --or--

    origVal = 0

    rVal = oBusObj.GetValue("cOldVal", origVal)

    This should work.

    Elliott

  • 0 in reply to jepritch

    Thanks Elliott, that works quite nicely in a quick test (v2021).

    	retVal = 0 : sMsg = ""
    	nOrigCredLimit = 0
    	sMsg = "column = " & cStr(column) & vbcrlf & "New value = " & cStr(value) & vbcrlf
    	retVal = oBusObj.GetValue("cOldVal$", nOrigCredLimit)
    	sMsg = sMsg & "nOrigCredLimit = " & cStr(nOrigCredLimit)
    	retVal = oSession.AsObject(oSession.UI).MessageBox("",sMsg)

    I really appreciate the speedy reply.