I should know this but I’m having a bit of trouble with calling a getRows method on the PO adapter.
I am passing in the PO Num, PO Line, and PO Rel Num to return a single PO Release record field.
My code is below:
private void oTrans_receiptAdapter_AfterAdapterMethod(object sender, AfterAdapterMethodArgs args)
{
// ** Argument Properties and Uses **
// ** args.MethodName **
// ** Add Event Handler Code **
// ** Use MessageBox to find adapter method name
// EpiMessageBox.Show(args.MethodName)
switch (args.MethodName)
{
case "GetDtlPOLineInfo":
//set rvcDtl.LotNum field from adapter method. This stopped working via BPM after the update to 10.2 in June 2018, so I'm tring a custom approach
int poNum = (int)edvRcvDtl.dataView[edvRcvDtl.Row]["PONum"];
int poLine = (int)edvRcvDtl.dataView[edvRcvDtl.Row]["POLine"];
//int poRelNum = (int)edvRcvDtl.dataView[edvRcvDtl.Row]["PORelNum"];
int poRelNum = 1;
try
{
//edvRcvDtl.dataView[edvRcvDtl.Row]["LotNum"] = ReturnLotFromAdapter(poNum, poLine, poRelNum);
MessageBox.Show((string)ReturnLotFromAdapter(poNum, poLine, poRelNum));
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
//MessageBox.Show(poNum.ToString() + poLine.ToString() + poRelNum.ToString());
break;
}
}
private string ReturnLotFromAdapter(int poNum, int poLine, int poRelNum)
{
string lot = null;
//use the adapter to return the lot num from the first release of the PO
using(POAdapter adapterPO = new POAdapter(oTrans))
{
adapterPO.BOConnect();
Ice.Lib.Searches.SearchOptions opts = new SearchOptions(SearchMode.AutoSearch);
opts.DataSetMode = DataSetMode.RowsDataSet;
string whereClausePOHeader = "PONum = poNum";
string whereClausePODtl ="POLine = poLine";
string whereClausePORel = "PORelNum = poRelNum";
opts.NamedSearch.WhereClauses.Add("POHeader", whereClausePOHeader);
opts.NamedSearch.WhereClauses.Add("PODetail", whereClausePODtl);
opts.NamedSearch.WhereClauses.Add("PORel", whereClausePORel);
bool more;
var dsPO = (Erp.BO.PODataSet)adapterPO.GetRows(opts, out more);
if(dsPO!=null)
{
//get the lot
//lot = (string)adapterPO.POData.PORel[0]["LotNum_c"];
lot = (string)dsPO.PORel[0]["LotNum_c"];
}
adapterPO.Dispose();
}
return lot;
}
I’ve verifed in the BL tester that this is indeed a good way to return the single row I am looking for from the dataset, but I get this exception when I run the code:
I am at a loss as to why this might be happening, any ideas are appreciated, thanks!