Error while updating ShipHead.ShipToNum at CustomerShipmentEntry For

Hi all,


after creating pack slips, there are instance where our sales team change the shipto address of an order.


when they change shipto address at orderentry, we expect it to be updated in shipment entry as well. But, it does not update. as a result, a pack slip is printed with old shipping address leading to wrong delivery location.


so, i have written program -  before printing pack slip, check whether shiphead.shiptonum = orderhed.shiptonum are same . if they are not same, update shiphead.shiptonum = orderhed.shiptonum.


below is program ... Epicor 9.05 700B not allowing me to update.

 

Private Sub baseToolbarsManager_ToolClick(ByVal sender As Object, ByVal args As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs)

If args.Tool.Key.ToString() Like "Print*" Then

Dim edvShipDtl As EpiDataView = CType(oTrans.EpiDataViews("ShipDtl"), EpiDataView)

 If edvShipDtl.dataView.Count > 0 Then

Dim edvShipHead As EpiDataView = CType(oTrans.EpiDataViews("ShipHead"), EpiDataView)

Dim ShipHeadShipToNum As String = edvShipHead.dataView(edvShipHead.Row)("ShipToNum")

Dim OrderHeadShipToNum As String = chkSOShipToNum(edvShipDtl.dataView(edvShipDtl.Row)("OrderNum")) /*this function brings me the orderhed.shiptonum */

If (ShipHeadShipToNum <> OrderHeadShipToNum) Then

edvShipHead.dataView(edvShipHead.Row).BeginEdit()

edvShipHead.dataView(edvShipHead.Row)("ShipToNum") = OrderHeadShipToNum   

edvShipHead.dataView(edvShipHead.Row).EndEdit()

oTrans.update()

oTrans.Refresh()

End If

End If

End If

End Sub


Private Function chkSOShipToNum(ByVal orderNum As Integer) as String

Dim SOShipToNum as String

Try 

' Declare and Initialize EpiDataView Variables

' Declare and create an instance of the Adapter.

Dim adapterSalesOrder As SalesOrderAdapter = New SalesOrderAdapter(Script.oTrans)

adapterSalesOrder.BOConnect()

adapterSalesOrder.clearData()

' Declare and Initialize Variables


' Call Adapter method

Dim res_SalesOrder As Boolean = adapterSalesOrder.GetByID(orderNum)

If res_SalesOrder = True Then

SOShipToNum = adapterSalesOrder.SalesOrderData.OrderHed(0).ShipToNum

Else

MessageBox.Show("SalesOrder Missing!")

End If

' Cleanup Adapter Reference

adapterSalesOrder.Dispose

Catch ex As System.Exception

ExceptionBox.Show(ex)

End Try

Return SOShipToNum

End Function


any help much appreciated !!


Reported to Epicor support... its been 3 weeks, no update from them till now!