Purchase Order Entry Script Not Visually Updating Field

SOLVED

I have a very basic script:

sWarehouse = ""

retVal = oBusObj.getValue("ShipToCode$", sWarehouse)
retVal = oBusObj.setValue("WarehouseCode$", sWarehouse)

It is set to run on Column-Post Validiate on the ShipToCode, our warehouses and ship to codes are the same and I want to copy from one field to the other. What currently happens is that you enter the ship to code and move to the next field, the description on the warehouse code changes to what it should be but the actual number in the field does not visually change. If you accept the purchase order and then go back in to it, the field will show the correct value. So the script works but I feel it might be confusing to have it not update the field visually, is there any way to make that work?

Sage 100 Advanced ERP 2014 (Version 5.10.1.0)

  • 0 in reply to Jon_K
    verified answer
    Maybe the InvokeChange method? (assuming 4.50 or above)

    Generic Example:

    retval = oUIObj.InvokeChange("ML_Customer",strVal)

    I have not tested this, but this appears to be tied to the form as opposed to the data object. ML_Customer is the button or control on the data entry form.

    The documentation says:

    "Used to change the value of a control on the screen or a column in a grid. This method may be useful for certain situations where there is unique logic associated with changing the value of a control on the screen or in a grid which is not invoked via oBusObj.SetValue(). E.G. Changing the quantity ordered in a sales order line does not update the "Total Amount" displayed on the lower right corner of the Lines tab."
  • 0
    verified answer

    Hi Jon_K

    Just an FYI in the 2015 release we added warehouse code to the ship-to address table.  But as you are on 2014 that isn't going to solve you're problem. [:)]

    The reason the screen isn't updating is because the "screen" object name is actually ML_WarehouseCode (this was done because of a conflict with the lines screen), so the business object value is getting changed, we just need to update the screen.  If you use InvokeChange() it will be as if the user had entered the value themselves. 

    So, you can add this to your script after the SetValue()

    sWarehouse = ""
    retVal = oBusObj.GetValue("ShipToCode$", sWarehouse)
    retVal = oBusObj.SetValue("WarehouseCode$", sWarehouse)

    If retVal<>0 Then
       ' Check to see a UI is present before trying to update the screen value.  This is the recommended method to do so
       MASUI = False
       IF (IsObject(oUIObj)) Then
          MASUI = True
       Else
          MASUI = CBool(oScript.UIObj)
          If (MASUI) Then
             Set oUIObj = oSession.AsObject(oScript.UIObj)
          End If
       End If

       If (MASUI) Then ' Set UI Value using InvokeChange()
          retVal = oUIObj.InvokeChange("ML_WarehouseCode", sWarehouse)
       End If
    End If

     

    Hope that helps.  

    Elliott

  • 0 in reply to jepritch
    Thank you Tom and Elliott, you guys are the best! Is there a place where I can get up to date scripting documentation? I have a document called ScriptingPlus-v170 that someone gave to me and it has some great info in it but InvokeChange isn't even mentioned there.
  • 0 in reply to Jon_K
    the latest version of the scripting doc is on the thread linked below it is based on the document you have.

    sagecity.na.sage.com/.../248311
  • 0 in reply to jepritch
    Thanks Elliot! I already got to use that technique on one of my own scripts. Specifically forcing an immediate update of the net invoice value on a sales order invoice.