PO Detail link to SO Detail

SUGGESTED

I see where you can source data from the SO Detail to the PO Detail but not seeing anything for the other way around.  What would be the best method to get the data from a UDF on the PO Detail lines to the same named UDF on the SO Detail lines?

  • 0

    Searched but do not see any post on this, would a script work?

  • 0

    Attempted to use same logic as a PO Receipt script writing back to the SO.  My debugging skills are not good by any means, so not sure what this means.  I have set a UDF on the SO for the lines in case we have the same item on multiple lines on one order.  Any suggestions on the debugging part? I have it set on a column post validate on the UDF_PURCHASING_NOTES in the PO.

    Script to transfer notes made on PO to SO in UDF field
    
    Dim sPurchaseOrderNo
    Dim sSalesOrderNo
    Dim sItemCode
    Dim sItemCodeCur
    Dim sPO_Notes
    Dim sSO_Notes
    Dim sOrderStatus
    Dim oSalesOrder
    
    sPurchaseOrderNo = ""
    sSalesOrderNo = ""
    sItemCode = ""
    sItemCodeCur = ""
    sPO_Notes = ""
    sSO_Notes = ""
    sOrderStatus = ""
    sPOSOLines = ""
    oSalesOrder = 0
    
    retVal = oBusObj.GetValue("SalesOrderNo$",sSalesOrderNo)
    r=oScript.DebugPrint("SalesOrderNo: " & sSalesOrderNo)
    
    if sSalesOrderNo <> "" then
    
    	retVal = oBusObj.GetValue("ItemCode$",sItemCode)
    	retVal = oBusObj.GetValue("UDF_PURCHASING_NOTES$", sPO_Notes)
    	retVal = oBusObj.GetValue("UDF_SOLINES$",sPOSOLines)
    
    	r=oScript.DebugPrint("ItemCode: " & sItemCode)
    
    	if sPO_Notes <> "" then
    
    		sPO_Notes = sSO_Notes
    		
    		oSalesOrder = oSession.GetObject("SO_SalesOrder_bus")
    		r=oScript.DebugPrint("After oSession.GetObj")
    
    		if oSalesOrder <> 0 then
    
    			Set oSalesOrder = oSession.AsObject(oSalesOrder)
    			r=oScript.DebugPrint("After AsObject for oSalesOrder")
    
    			retVal = oSalesOrder.SetKeyValue("SalesOrderNo$", sSalesOrderNo)
    			retVal = oSalesOrder.SetKey()
    
    			if retVal = 1 Then
    			
    				r=oScript.DebugPrint("After Successful SO SetKey ")
    
    				retVal = oSalesOrder.GetValue("OrderStatus$",sOrderStatus)
    				r=oScript.DebugPrint("OrderStatus: " & sOrderStatus)
    
    	
    				Set oSOLine = oSalesOrder.AsObject(oSalesOrder.Lines)
    '				retVal = oSOLine.SetKeyValue("SalesOrderNo$", sSalesOrderNo)
    '				retVal = oSOLine.SetKeyValue("LineKey$", sSOLines)
    '				retVal = oSOLine.SetKey()
    
    				r=oScript.DebugPrint("After AsObject oSOLines ")
    
    				retVal = oSOLine.MoveFirst()
    				r=oScript.DebugPrint("After MoveFirst ")
    				sLineSONo=""
    				sSOLinesKey = ""
    				retVal = oSOLine.GetValue("SalesOrderNo$",sLineSONo)
    				r=oScript.DebugPrint("Lines SO Num " & sLineSONo)
    
    
    				lineUpdated = 0 ' initialize new indicator
    
    				do until (oSOLine.Eof or lineUpdated=1)
    
    					retVal = oSOLine.GetValue("ItemCode$",sItemCodeCur)
    					retVal = oSOLine.GetValue("LineKey$",sSOLinesKey)
    					r=oScript.DebugPrint("CurrentItemCode: " & sItemCodeCur)
    					r=oScript.DebugPrint("CurrentItemCode: " & sItemCodeCur)
    																							
    					if sItemCode = sItemCodeCur AND (sOrderStatus = "N" Or sOrderStatus ="O") And sSOLinesKey = sPOSOLines Then
    
    						retVal = oSOLine.SetValue("UDF_PURCHASING_NOTES$",sSO_Notes)
    						retVal = oSOLine.Write()
    						lineUpdated = 1 'trip flag
    						r=oScript.DebugPrint("retVal on oSOLine Write: " & CStr(retVal))
    						r=oScript.DebugPrint("lineUpdated = " & CStr(lineUpdated))
    											
    					end if
    					retVal = oSOLine.MoveNext()
    				loop
    							
    				if lineUpdated=1 then ' only write if we found a match
    								
    					retVal = oSalesOrder.Write()
    					r=oScript.DebugPrint("retVal on oSalesOrder Write: " & CStr(retVal))
    
    				end if
    
    				retVal = oSOLine.MoveNext()									
    						
    			end If
    		End If
    	end if
    
    end if

  • 0 in reply to jland47
    SUGGESTED

    Figured out answer after a couples hours of tinkering, one type-o and what is the reasoning for the order of the variable "sPO_Notes = sSO_Notes" which was wrong and the script worked if I switched the order to "sSO_Notes = sPO_Notes"?