Launch Search and return selected value

I’m trying to call a search dialog based on an adapter. I’ve successfully done this, but I’d really like it to return data that has been filtered and joined in with another table.

My first problem is it seems to ignore my where clause. My second problem is how to return the selected value.

Does anyone have experience launching a custom search like this?

	//launch search filtered to customers that exist in whse CONCUS that have consignment bins
	//gather valid ship tos
	Ice.Lib.Searches.SearchOptions optsST = new SearchOptions(SearchMode.ShowDialog);
	string whereClauseST = "Company = 'ALLO' and ConBinNum_c is not null and ConBinNum_c <> ''";
	optsST.NamedSearch.WhereClauses.Add("ShipTo", whereClauseST);
	ProcessCaller.LaunchSearch(oTrans, "ShipToAdapter", optsST);

I’m not sure about how to get results from a process call like that but see
below for a work around.

For the where clause, maybe you could try a more basic one just to ensure
it’s working.

You could definitely do exactly what you’re wanting by using the adapter
direct. I’ll give an example once I get to a PC

why can’t you use the simple search wizard?

1 Like

Jose does the simple search allow for multiple criteria? I haven’t used it with the dialog.

Here’s how I’d do it with an adapter (I’m using parttran adapter in this case):

bool more;
PartTranAdapter tranAdapter = new PartTranAdapter(oTrans);
tranAdapter.BOConnect();
SearchOptions optsTrans = new SearchOptions(SearchMode.AutoSearch); 
optsTrans.PageSize = 20; //return this many
string whereTrans = string.Format("JobNum = '{0}' and TranType = 'MFG-STK'", JobEdit.Text); //2 days of data tops
optsTrans.NamedSearch.WhereClauses.Add("PartTran",whereTrans); 
var trans = tranAdapter.GetRows(optsTrans,out more);

TransGrid.DataSource = trans;

You can also access the data in the dataset (trans in thiis case) like:
trans.Tables[0].Rows[0][1]

You will want to use the adapter wizard to make sure it pulls in all the necessary references.

Also, you want to change the searchmode to: SearchMode.ShowDialog

1 Like

Thanks Chris, I think this is a good place to start. I think this is very similar to what I’ve currently done, except your whereTrans probably works and mine doesn’t! What’s interesting is that on the Business Logic Tester, my whereClause works perfectly, but doesn’t seem to work in my code. I took out the process caller, but now I’m not sure how to get the search dialog to show.

  Ice.Lib.Searches.SearchOptions optsST = new SearchOptions(SearchMode.ShowDialog);
  string whereClauseST = "Company = 'ALLO' and ConBinNum_c is not null and ConBinNum_c <> ''";
  optsST.NamedSearch.WhereClauses.Add("ShipTo", whereClauseST);

Secondly, I’m wondering if I need a totally different approach to this.
The requirement is to mimic a customer/ship to search like you’d see in a sales order. The user would first select the customer, then select the ship to based on the customer chosen.

The customer list should be filtered to only those customers who have a ship to that meet a certain criteria.

It’s sort of a chicken/egg scenario here in my opinion as far as choosing a customer and then the ship to, but really the ship to drives which customers can be chosen.

Any ideas? :slight_smile:

Looks like you’re right, this appears to be the most simple solution. I’ll get it working and report back

1 Like

2 simple searches were implemented. I unfortunately did not know of a easy way to filter the first customer search the way I wanted to. However, I did filter the Ship To simple search based on the results of the customer search.

private void SearchOnShipToAdapterShowDialog()
{
EpiDataView edvheadView = ((EpiDataView)(this.oTrans.EpiDataViews[“headView”]));
System.Data.DataRow edvheadViewRow = edvheadView.CurrentDataRow;
if((int)edvheadViewRow[“ConCustNum_c”]!=0)
{
bool recSelected;
string whereClause = string.Format(“CustNum = {0} and ConBinNum_c is not null and ConBinNum_c <> ‘’”, edvheadViewRow[“ConCustNum_c”].ToString());
System.Data.DataSet dsShipToAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, “ShipToAdapter”, out recSelected, true, whereClause);
if (recSelected)
{
System.Data.DataRow adapterRow = dsShipToAdapter.Tables[0].Rows[0];

  		// Map Search Fields to Application Fields

  		if ((edvheadViewRow != null))
  		{
  			edvheadViewRow.BeginEdit();
  			edvheadViewRow["ConShipToNum_c"] = adapterRow["ShipToNum"];
  			edvheadViewRow.EndEdit();
  		}
  	}
  }

}

1 Like

If I were in your shoes at this point, I might consider another option:

write a baq to give the results you want, for the variable condition (company), make it a parameter. Then you can use DynamicQueryAdapter (see @josecgomez awesome video) to dynamically use the BAQ and pass your parameter (which can be selected from a drop down list or even autocomplete). I’ve found this to be the simplest way to get specific sets of data.

1 Like

Sorry to dig up an old post, but is the Simple Search Wizard in version 10.1.400? I’m not seeing it anywhere but I’ve seen a few people say to use the Simple Search Wizard in e10…

Yeah its in Customization -> Tools -> Wizard

1 Like

Nevermind… I was trying to find it in the dashboard view - you actually have to deploy the dashboard and have it on the menu and then go to to the Customization menu

1 Like

I know this is old, but I found a new way that I like, it’s available on the PartAdapter, and I imagine it lives on other adapters as well.

//these will hold the result
string part;
string desc;

SearchOptions opts = new SearchOptions(SearchMode.ShowDialog);
		opts.PreLoadSearchFilter = "InActive=false AND TypeCode = 'M'";
		opts.DataSetMode = DataSetMode.ListDataSet;
		
		if(PartAdapter.InvokeSingleSelectSearch(oTrans,opts,out part, out desc))
		{
		    //now i can use my part/desc vars
                }

Note that this is a static method and doesnt require an instance of a PartAdapter. Also, note it is intended for single selections

1 Like