object selected = ProcessCaller.InvokeAdapterMethod(oTrans.EpiBaseForm, "QuickSearchAdapter", "ShowQuickSearchForm", new object[] { oTrans.EpiBaseForm, "quickSerach01", false, new DataTable()});
How to add default parameters to Quick Search through customization ? I used the code below but it return some error. I replace the “new DataTable()” with "defaultConditions ".
I use a quick search with default parameters on the sales order entry. In my case I need to pass in CustID to the search to filter by order history. I don’t have the original source handy but it was from elsewhere on this forum and I’ve adjusted it to work for me.
sender = oTrans.EpiBaseForm;
QuickSearchAdapter _qdA = new QuickSearchAdapter(oTrans);
_qdA.BOConnect();
_qdA.GetByID("","CustXRefSearch");
QuickSearchDataSet qsds = _qdA.QuickSearchData;
// Loop through all criteria to find what I want. Only Constant type seem to work with passed in values
foreach(QuickSearchDataSet.QuickSearchCriteriaRow r in qsds.QuickSearchCriteria) {
if(r.FieldName.Equals("CustID") && r.CriteriaType.Equals("Constant")) {
r.CriteriaValue = edvH.CurrentDataRow["CustomerCustID"].ToString();
break;
}
}
using(QuickSearchPanel panel = _qdA.GetQuickSearchPanel(oTrans.EpiBaseForm)) {
if(panel !=null) {
using(QuickSearchForm form = new QuickSearchForm(_qdA)) {
form.LastQS = "CustXRefSearch";
System.Reflection.MethodInfo mi = form.GetType().GetMethod("addQuickSearchPanel",System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
mi.Invoke(form, new object[]{panel});
SearchOptions options = SearchOptions.CreateSearchForm(DataSetMode.ListDataSet);
options.Sender = sender;
options.SelectMode = SelectMode.SingleSelect;
form.ShowDialog(new Ice.Lib.Searches.EpiSearchEngine((EpiBaseAdapter)_qdA),options);
System.Reflection.FieldInfo fi = form.GetType().GetField("selectObject", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
object ret = fi.GetValue(form);
if(ret!=null) {
// Do something with ret value
}
}
}
}