Where Clause with Search Adapter in Customization

I’m hoping this is an easy one for someone. I am trying to call the PORelSearchAdapter on my Nonconformance screen so I can select a PO/Line/Rel to put on the Nonconformance… However, I am trying to write the Where clause so that the search is limited to just the PO/Line/Rels that have the part number entered on the Nonconformance screen. I’ve tried a few combinations but I am missing it… help?

string whereClause = "POLinePartNum = '261991'";

Need more code to see if it’s a named, runtime, listlookup, etc etc

private void SearchOnPORelSearchAdapterShowDialog()
	{
		bool recSelected;
		string whereClause = String.Empty;
		
		System.Data.DataSet dsPORelSearchAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "PORelSearchAdapter", out recSelected, true, whereClause);
		if (recSelected)
		{
			System.Data.DataRow adapterRow = dsPORelSearchAdapter.Tables[0].Rows[0];

			// Map Search Fields to Application Fields
			EpiDataView edvNonConf = ((EpiDataView)(this.oTrans.EpiDataViews["NonConf"]));
			System.Data.DataRow edvNonConfRow = edvNonConf.CurrentDataRow;
			if ((edvNonConfRow != null))
			{
				edvNonConfRow.BeginEdit();
				edvNonConfRow["PONum"] = adapterRow["PONum"];
				edvNonConfRow["POLine"] = adapterRow["POLine"];
				edvNonConfRow["PORelNum"] = adapterRow["PORelNum"];
				edvNonConfRow["VendorNumVendorID"] = adapterRow["VendorID"];
				edvNonConfRow["VendorNumName"] = adapterRow["VendorName"];
				edvNonConfRow.EndEdit();
			}
		}
	}

That listLookup just uses an SQL string for the where is it just a matter of forgetting the “.” in POLine.PartNum?

Well I wasn’t sure what the field was… I looked at the wizard to adapt the rows and the field name appears to be “POLinePartNum”. I thought the search just needed the column name, not the table.column. I’ll try it though. Easy enough.

Error Logs say POLinePartNum is not a valid column name. Nor is POLine.PartNum.

PODetail.PartNum maybe?

1 Like

^ yeah what he said PODetail that’s the table. Though you’re trying to use a PORel search adapter so I’m not sure what’s all available there for filtering.

Yeah that’s what I’m trying to figure out… In the code that the wizard creates, it lists out the column names of the adapter to match them up with the epiDataView. The PartNum one appears to be POLinePartNum - similarly anything else from the POLine starts with POLine + whatever. Is there a place that uses this adapter natively that I could trace and see if it sheds some light?

Moving on slightly now that I vaguely understand why it’s not working the way I want…

I read a suggestion from another post to create a Quick Search on the search form I’m trying to work with so that I can control what columns show up… but it seems that no matter what columns I show, only what’s available in the PORelList table actually is available for me to do something with the returned row… and I also haven’t figured out anyway to populate the where clause to get anything to filter. Can’t use a parameter on the BAQ… or at least I haven’t figured out a way to fill it from the Quick Search.

So it’s led me to a new thought. Can I use the search button to call a BAQ GetRows and then get the returned selected row and do something with it? I’m stuck because I know the Search adapters appear to be “pre-wired” so that all I need to do is call them and then they call a Search method of sorts and then whatever row is selected, it returns it as a returned row. I don’t believe a DynamicQueryAdapter will do that so easily. With all that said, my goal is to search PO Releases by PartNum entered on the Nonconformance, select a Release, and then tie the PO and supplier info to the Nonconformance record and ultimately all the way to DMR should it get there. Maybe there’s a better way? I’m open to ideas at this point.

So the table that is returned can be seen by looking at PORelList in Extended Properties. Columns marked as “External” don’t seem to be able to be searched on but they are returned in the resulting dataset.