Search UD Child table on non key field with C#. Example: Are there any records where UD100A.Character01 = “blah”
Sure, you could definitely use a DynamicQuery implementation to search this and then handle the search logic on the BAQ side or you could use a BOReader implementation to invoke a search on the UD100A BO and handle that with your whereClause.
BOReader is much faster than a BAQ which I was trying to avoid. I’ll try it that way. Thanks.
You need to use a Runtime Search and Hashtable
BOReader Example
private string GetUserCodeSetting(string CodeTypeID, string CodeID)
{
// Ice.Contracts.Lib.BOReader Must be Added to Assembly
Ice.Proxy.Lib.BOReaderImpl bor = WCFServiceSupport.CreateImpl<Ice.Proxy.Lib.BOReaderImpl>((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.BOReaderSvcContract>.UriPath);
string whereClause = string.Format(" UDCodeType.CodeTypeID = '{0}'", CodeTypeID);
DataSet dsUDCodes = bor.GetRows("Ice:BO:UserCodes", whereClause, string.Empty);
if (dsUDCodes.Tables[0].Rows.Count > 0)
{
string subWhereClause = string.Format("CodeID = '{0}'", CodeID);
return dsUDCodes.Tables["UDCodes"].Select(subWhereClause)[0]["LongDesc"].ToString();
}
return string.Empty;
}
RuntimeSearch Example
private string GetVehicleName(string oem_key, string vehicle_key)
{
// create Hashtable of tableName
System.Collections.Hashtable myHash = new System.Collections.Hashtable();
string wClause = "Key1 = '" + oem_key + "' and ChildKey1 = '" + vehicle_key + "'";
// add table name (key) and where clause to Hashtable
myHash.Add("UD100A", wClause);
// Create SearchOptions object
SearchOptions opts = Ice.Lib.Searches.SearchOptions.CreateRuntimeSearch(myHash, DataSetMode.RowsDataSet);
// Call Adapter InvokeSearch()
ud100Adapter.InvokeSearch(opts);
if (ud100Adapter.UD100Data.UD100A.Rows.Count > 0)
{
return ud100Adapter.UD100Data.UD100A[0]["Character01"].ToString();
}
return "";
}
Example Filling Combo with UD100A
Just for the sake since we are talking about UD100A
private void FillUD100ACombo(string key1)
{
// create Hashtable of tableName
System.Collections.Hashtable myHash = new System.Collections.Hashtable();
string wClause = "Key1 = '" + key1 + "'";
// add table name (key) and where clause to Hashtable
myHash.Add("UD100A", wClause);
// Create SearchOptions object
SearchOptions opts = Ice.Lib.Searches.SearchOptions.CreateRuntimeSearch(myHash, DataSetMode.RowsDataSet);
// Call Adapter InvokeSearch()
ud100Adapter.InvokeSearch(opts);
// Set EpiUltraCombo Properties
this.comboUltraPrograms.ValueMember = "ChildKey1";
this.comboUltraPrograms.DataSource = ud100Adapter.UD100Data.UD100A;
this.comboUltraPrograms.DisplayMember = "Character01";
string[] fields = new string[] {"Character01"};
this.comboUltraPrograms.SetColumnFilter(fields);
}
1 Like