Copy Data From One Field To Another In Customer Shipment Entry

Good morning experts! I’m hoping someone can help with this, it seems like it should be simple but I can’t get it to work. I am customizing the Customer Shipment Entry form because we mostly ship our product to an installer, who then delivers it to the site for installation. For this reason I have changed the existing “Ship To” group to “Site” and created a new ship to area to show either the installer’s address or the site address. I’ve got the code worked out to show the installer address if the product ships to installer, but can’t get it to show the site address if it ships directly to the site.

I’ve got the code in the “oTrans_adapter_AfterAdapterMethod” event, under “POGetDtlList”, which is the last thing triggered before the data shows on the form.

Here’s the code I’m using to test the adapter connection…

SalesOrderAdapter adOrd = new SalesOrderAdapter(oTrans);
adOrd.BOConnect();
adOrd.GetByID(orderNum);

ShipToAdapter adShipTo = new ShipToAdapter(oTrans);
adShipTo.BOConnect();
adShipTo.GetByID(adOrd.SalesOrderData.Tables[“OrderHed”].Rows[0][“ShipToCustNum”].ToString());

MessageBox.Show(adShipTo.ShipToData.Tables[“ShipTo”].Rows[0][“Name”].ToString());

And here’s the error message that I get…

It would be nice if I could simply say the Ship To TextBox.Text equals the Site TextBox.Text, but since the data loads after the “POGetDtlList”, that only results in a blank TextBox.

Thanks for your time and for any help you can provide! Have a great day!

It appears that the GetByID on ShipTo isn’t returning a value.

Double check that the GetById on the sales order is working and returning the order of interest. Verify that ShipToCustNum has a value in it.

1 Like

Thanks for the reply James!

I added a message box to show if the ShipToCustNum had a value, and it returned 31.

ShipToAdapter adShipTo = new ShipToAdapter(oTrans);
adShipTo.BOConnect();
adShipTo.GetByID(adOrd.SalesOrderData.Tables[“OrderHed”].Rows[0][“ShipToCustNum”].ToString());

MessageBox.Show(adOrd.SalesOrderData.Tables[“OrderHed”].Rows[0][“ShipToCustNum”].ToString());
MessageBox.Show(adShipTo.ShipToData.Tables[“ShipTo”].Rows[0][“Name”].ToString());

I create a BAQ with ShipHead and ShipTo…

The results show that there is a CustNum of 31 in the ShipTo table…

Can’t understand why I’m getting the error.

Hi,

Method adShipTo.GetByID need one integer CustNum and one string Ship To Num.
adShipTo.GetByID(int32 custNum, String shipToNum)

1 Like

Thank you Jaicker_Avila! Once again, you save me. It didn’t even occur to me that it took two values in the GetByID method. That’s one thing I miss about using Visual Studio, it would give you hints to what was required.

Thanks again!

1 Like

I think the adapter may be the wrong choice. The Customer adapter is likely the one to use it has a method. GetShipTo(custID, shipToNum) the ShipTo adapter doesn’t have a method that accepts customer number and a shipto

Object explorer shows what methods and properties are available on an adapter

1 Like