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));
}
}
}
}