Need Help with Customer Shipment Entry Customization

Happy Friday everyone! I’ve got an issue that I can’t seem to resolve, and have spent the day trying to research it with minimal results.

I’m customizing the Customer Shipment Entry form to show an added area that will list either the original ship to address or the selected installer address. The reason is that some times we will ship our product straight to an installer, who will then deliver it to the site for installation. Below is what it will look like…

We have 3 UD table fields in the OrderHed table:
ShipToInstaller_c - boolean for a checkbox on Sales Order Entry form
VendorID_c - holds vendor ID
VendorName_c - holds vendor name

I have references added…

I have code that connects to the OrderHed table and UD table field values. If the ship to installer field is “true” then it should connect to the vendor table and get the installer address to show on the form. In the code below you can see what I have so far, and that I’ve created message boxes to return data to be sure I was getting the correct info…

private void oTrans_adapter_AfterAdapterMethod(object sender, AfterAdapterMethodArgs args)
{
// ** Argument Properties and Uses **
// ** args.MethodName **
// ** Add Event Handler Code **

  // ** Use MessageBox to find adapter method name
  // EpiMessageBox.Show(args.MethodName)

//MessageBox.Show(args.MethodName);

  switch (args.MethodName)
  {
  	case "POGetDtlList":
  		// Create TextBox Objects linked to Ship To fields
  		EpiTextBox txtBoxShipTo = ((EpiTextBox)csm.GetNativeControlReference("8a68c68d-4baa-4d6e-977b-a7da8c0ffb29"));
  		// Create TextBox Object linked to Order Number field
  		EpiNumericEditor txtBoxName = ((EpiNumericEditor)csm.GetNativeControlReference("7881ca23-0a34-49b7-9f30-e54e26e42a35"));
  		int orderNum = (int)Convert.ChangeType(txtBoxName.Text, typeof(int));
  		if (orderNum != 0)
  		{
  			// Get the sales order 
  			SalesOrderAdapter adOrd = new SalesOrderAdapter(oTrans);
  			adOrd.BOConnect();
  			adOrd.GetByID(orderNum);

  			// See if Ship To Installer is checked
  			if ((bool)Convert.ChangeType(adOrd.SalesOrderData.Tables["OrderHed"].Rows[0]["ShipToInstaller_c"], typeof(bool)) == true)
  			{
  				// Get the vendor
  				VendorAdapter adVend = new VendorAdapter(oTrans);
  				adVend.BOConnect();
  				adVend.GetByID(adOrd.SalesOrderData.Tables["OrderHed"].Rows[0]["VendorID_c"]);

// Show the UDTable field VendorID…
MessageBox.Show(adOrd.SalesOrderData.Tables[“OrderHed”].Rows[0][“VendorID_c”].ToString());

// Show the vendor name from the vendor table…
MessageBox.Show(adVend.VendorData.Tables[“Vendor”].Rows[0][“Name”].ToString());

// Add text to field…
txtBoxShipTo.Text = “Ship to installer!”;

  			}

// Show if ship to installer is true or false from UDTable field…
MessageBox.Show(adOrd.SalesOrderData.Tables[“OrderHed”].Rows[0][“ShipToInstaller_c”].ToString());

// Show vendor name from UDTable field…
MessageBox.Show(adOrd.SalesOrderData.Tables[“OrderHed”].Rows[0][“VendorName_c”].ToString());
}

  		break;
  	case "Update":
  		break;
  }

}
}

The first message box shows the UD table VendorID_c without errors. The second message box triggers the following error…

But if I comment out that second message box, the code runs and adds “Ship to installer!” into the textbox field and the 3rd and 4th message boxes show without errors.

Not sure why I get the error for the vendor message box, when it follows the same code layout as the sales order code. Thanks in advance for any help you can provide! Have a great weekend!

You must change this line:

To:
adVend.GetByID(adOrd.SalesOrderData.Tables[“OrderHed”].Rows[0][“VendorID_c”].ToString());

1 Like

Thank you so much Jaicker_Avila! Funny how something so simply can cause hours of headache.

1 Like