Problem with script updating UDF with date based on SO header order status

Hey all, 

I need to write a script that can put the current date into a UDF when the Order Status is changed from "Hold" to "Open".

We have the release date UDF set as a table-post-write.

This is the code so far.

 
TMPStatus=0
Date=0
 
 
retval=oBusObj.GetValue("OrderStatus$",TMPStatus)
 
if TMPStatus = "O" then
 
retval=oBusObj.SetValue(“UDF_Release_Date”, date)
 
end if

I'm really new to this and I'm not sure what I'm doing wrong. Any help would be greatly appreciated.

Thanks
  • 0

    You can do it this way:

    SO_SalesOrderHeader - Post Read (save the old value of OrderStatus$)

    origStatus = ""

    retVal = oBusObj.GetValue("OrderStatus$", origStatus)

    retVal = oScript.SetStorageVar("OrigOrderStatus", origStatus)

    SO_SalesOrderHeader - Pre Write (set UDF value, date needs to be in YYYYMMDD format)

    origStatus = ""

    status = ""

    retVal = oScript.GetStorageVar("OrigOrderStatus", origStatus)

    retVal = oBusObj.GetValue("OrderStatus", status)

    If origStatus = "H" and status = "O" then

       retVal = oBusObj.SetValue("UDF_Release_Date$", oSession.SystemDate)

    end if