Customer Search Button won't return all fields to form

Hello

I have a search button in Miscellaneous Shipments that looks at only the customer records, I then need to be able to return that data to the form. The standard search is not very useful for us.

I can only get certain fields to populate as it appears that the method I am using only returns the data retrieved in the search window. (this was already coded for us with CustNum and Name but we noticed that the address fields in the form were not being populated)

I can get Name, CustNum, City, Zip, State to work but I get an error for Address1, Address2, Address3, "not found in CustomerList

I understand from searching this forum I need to use the Get Rows method to retrieve all the customer data to return these fields, but I have no Idea how to do this.

I have tried using a QuickSearch instead but am getting the same problem only the name is returned to the form, no address details.

Thank you in advance

The Full code from the customisation

// **************************************************
// Custom code for MiscShipForm
// Created: 09/11/2016 16:56:05
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;

public class Script
{
// ** Wizard Insert Location - Do Not Remove ‘Begin/End Wizard Added Module Level Variables’ Comments! **
// Begin Wizard Added Module Level Variables **

// End Wizard Added Module Level Variables **

// Add Custom Module Level Variables Here **

public void InitializeCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
	// Begin Wizard Added Variable Initialization

	// End Wizard Added Variable Initialization

	// Begin Wizard Added Custom Method Calls

	this.btnCustSearch.Click += new System.EventHandler(this.btnCustSearch_Click);

	// End Wizard Added Custom Method Calls
}

public void DestroyCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
	// Begin Wizard Added Object Disposal

	this.btnCustSearch.Click -= new System.EventHandler(this.btnCustSearch_Click);
	// End Wizard Added Object Disposal

	// Begin Custom Code Disposal

	// End Custom Code Disposal
}

private void btnCustSearch_Click(object sender, System.EventArgs args)
{
	// ** Place Event Handling Code Here **
	bool recSelected;

	System.Data.DataSet dsCustomerAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "CustomerAdapter", out recSelected, true, "");
	if (recSelected)
	{
		EpiDataView edvMscShpHdView = ((EpiDataView)(this.oTrans.EpiDataViews["MscShpHd"]));
		System.Data.DataRow MscShpHdRow = edvMscShpHdView.CurrentDataRow;    
		
		System.Data.DataRow adapterRow = dsCustomerAdapter.Tables[0].Rows[0];

		// Map Search Fields to Application Fields
		if ((MscShpHdRow != null))
		{
			MscShpHdRow.BeginEdit();
			MscShpHdRow["Name"] = adapterRow["Name"];
			MscShpHdRow["CustNum"] = adapterRow["CustNum"];
			MscShpHdRow["Address1"] = adapterRow["Address1"];				
			MscShpHdRow["Address2"] = adapterRow["Address2"];
			MscShpHdRow["Address3"] = adapterRow["Address3"];
			MscShpHdRow["State"] = adapterRow["State"];
			MscShpHdRow["Zip"] = adapterRow["Zip"];
			MscShpHdRow["City"] = adapterRow["City"];
			MscShpHdRow["CountryNum"] = adapterRow["CountryNum"];
			MscShpHdRow.EndEdit();
 		   edvMscShpHdView.Notify(new EpiNotifyArgs(MiscShipForm, edvMscShpHdView.Row, edvMscShpHdView.Column));
		}
	}
}

}

I’d be curious to see if your GetRows is actually getting data or if you are just having a problem getting your data to stick in the DataView. You could use MessageBox.Show(adapterRow[“Address1”].ToString)() to verify the first case. (Also, I’d be curious is you can cast the results of that DataRow to a CustomerRow and have the typed data available)

That’s another thing to check - do you have to manually use ToString() to get the string value?

For the second case, can you manually assign some string to your row and get it to display?

If the problem turns out to be the DataView not updating and you give up with the DataView you could always manually populate the Edit box. Then if you Enter and Leave it (focus, lose focus) - it will update the EpiBound field.

Also, maybe try editing the DataView directly

EpiDataView edvRQ = (EpiDataView)(oTrans.EpiDataViews[“RQ”]);
edvRQ.dataView[edvRQ.Row][“CurrentQty”] = QtyEdit.Text;
oTrans.LastView = edvRQ;
oTrans.LastControl = QtyEdit;
oTrans.focusLast();

Thankyou for your reply’s

I should have mentioned that I am not very good at code at all so am not sure how to implement some of your suggestions.

However in your first reply I did try adding a static value to the address1

MscShpHdRow[“Address1”] = “TEST1”;

this then populated Address Line 1 with TEST1

1 Like

That’s a positive step - we can check that off the list.

The next step is to debug what’s happening. The easiest way to do this is with liberal use of MessageBox.Show(“Your message here”). This allows to ensure what conditions are being met, for example does MscShpHdRow ever become != null? Just past the condition put a msgbox like MessageBox.Show(“MscShpHd != null”) so you know it hit.

Also I feel like you need to add .ToString() to the end of your adapter rows… I could be wrong.

Thank you

I have added the message box as below
if ((MscShpHdRow != null))
{
MscShpHdRow.BeginEdit();
MscShpHdRow[“Name”] = adapterRow[“Name”];
MscShpHdRow[“CustNum”] = adapterRow[“CustNum”];
//MscShpHdRow[“Address1”] = “TEST1”;
MscShpHdRow.EndEdit();
edvMscShpHdView.Notify(new EpiNotifyArgs(MiscShipForm, edvMscShpHdView.Row, edvMscShpHdView.Column));
MessageBox.Show(“MscShpHd != null”);
}

I then get this when selecting an address

I don’t do much in material management, but I took a quick look at the Miscellaneous Shipment form. In your original post you mentioned that you have a button that looks at only the customer records, is this meant to replace the normal search on the ship to section?

If it is and the default button on the form is not populating all the information, I would check if you have any BPMs on the MiscShipToSearch method and that you have shiptos configured on your customers. I recall that by default when you create a customer it automatically creates a ship to, but it you cannot see it through customer ship to (don’t ask me why, just take a look at the ShipTo table and you will see the info.)

Don’t forget to try things with the base version of the form also.

If I am totally off the mark about the reason for the button, then I have learnt something about the Misc Ship form :grinning:

Once again this is all E9 so it might be a bit different in E10.

Hi, Thanks for your message

The reason for customisation is that with the standard search option the search as you said looks at all the ship to addresses for all the customers and suppliers in the system, as you cannot search by ID only Name you get a huge list which is cumbersome to look through. The default button populates the records correctly, My search is the problem :slight_smile:

As the sales department use this the most and mostly Misc Ship to our distributors they search by CustID as they get to know the different ID’s quite well, this in turn makes the form a lot easier for them to use.

I could get this to work but the way the customisation uses the customer adaptor it only brings back what is in the search window. Address1 Address2, Address3 are missing from the window

I can get City, State, and Country to work as they are in the search.

Mark,
I understand thanks.

Ooooh? So you want a more powerful search to be able to use different fields? It would be much quicker and easier then to try out a BAQ search or BAQ zone

Check out: EpicorICETools_UserGuide_31400.pdf around page 196

Also, it looks like you are reaching your code, it just isn’t having the desired effects. Try changing:
MscShpHdRow[“Name”] = adapterRow[“Name”];
MscShpHdRow[“CustNum”] = adapterRow[“CustNum”];

to

MscShpHdRow[“Name”] = adapterRow[“Name”].ToString();
MscShpHdRow[“CustNum”] = adapterRow[“CustNum”].ToString()

I’d probably do a check to ensure that dsCustomerAdapter.Tables[0].Rows.Count is not = 0. If it is, your search is not returning data