Pulling the Invoice Date into Chart Tracker

I’m working on a customization to pull the AP Invoice Date into the Chart Tracker Transaction Detail grid.
I have it pull the APInvoiceNum from the grid and pass it to the below function, however I’m getting a “There’s no row at position 0” error which is telling me nothing is coming back from the dataset.
I confirmed that it’s properly getting the invcNum string. How else can I debug this dataset?

private string CallAPInvoiceAdapterGetDataMethod(string invcNum)
{
	try
	{
		if( invcNum == "" )
			return "";

		APInvoiceAdapter adapterAPInvoice = new APInvoiceAdapter(this.oTrans);
		adapterAPInvoice.BOConnect();


		System.Data.DataSet dsAPInvoice = adapterAPInvoice.GetData(invcNum);
		string invcDate = "";
		invcDate = dsAPInvoice.Tables["APInvHed"].Rows[0]["InvoiceDate"].ToString();

		adapterAPInvoice.Dispose();
		return invcDate;

	} 
	catch (System.Exception ex){return "";}
}

Anyone have any ideas?

You can use something like this -

	private void CallAPInvoiceAdapterGetCurrentDataSetMethod()
	{
		try
		{
			// Declare and Initialize EpiDataView Variables
			// Declare and create an instance of the Adapter.
			APInvoiceAdapter adapterAPInvoice = new APInvoiceAdapter(this.oTrans);
			adapterAPInvoice.BOConnect();

			// Declare and Initialize Variables
			bool morePages;
			string InvcDate = "";
			string InvoiceNum = "123";
			SearchOptions opts = new SearchOptions(SearchMode.AutoSearch);
			opts.DataSetMode = DataSetMode.RowsDataSet;
			opts.NamedSearch.WhereClauses.Add("APInvHed","InvoiceNum = " + InvoiceNum );
			opts.PageSize = 0;
			// Call Adapter method
			DataSet dsAPInvoice = adapterAPInvoice.GetRows(opts, out morePages);
			InvcDate = dsAPInvoice.Tables["APInvHed"].Rows[0]["InvoiceDate"].ToString();
			// Cleanup Adapter Reference
			adapterAPInvoice.Dispose();

		} catch (System.Exception ex)
		{
			ExceptionBox.Show(ex);
		}
	}

Thanks! I had to add single quotes around the invoice num in the where clause, but that got me going.

@danbedwards my next question would be… Is there any way to make this more efficient? Going on and querying something for every transaction line has (obviously) diminished performance quite a bit.

Yes, you can do something like this -

1 Like