Script to copy a header field to all detail fields

I am trying to copy a header field (PO_PurchaseOrderHeader - UDF_REQ_SHIP_DATE) to a field in (PO_PurchaseOrderDetail - UDF_HEADERSHIPDATE)

I tried the following script:

retVal = 0
headershipdate = ""
retVal = GetValue("UDF_REQ_SHIP_DATE$",headershipdate)

Set oLines = oBusObj.AsObject(oBusObj.Lines)
retVal = oLines.MoveFirst()
Do Until CBool(oLines.EOF) = True

retVal=oLines.SetValue(UDF_HEADERSHIPDATE, headershipdate)
retVal = oLines.MoveNext()
Loop

I set it to run on the PO_Header on Table - Pre-Write

Is my script wrong or do I have the wrong event(s) chosen?

Sage 100 2018 SQL

Parents Reply Children