BAQ DataView in Dashboard

I am not very familiar with BAQ DataViews, but I did do some digging and it looks like it’s relatively painless to set up the dataview and bind it to the transaction object within a form. It looks like then, you subscribe the data in the BAQ dataview to a column(s) in another view to relate the data.

I have a dashboard assembly that already uses some pub/sub dashboard features in order to drive the data in the different panels.

The end goal is to bring in a new column into one of the queries/panels with the results from a separate BAQ. These are currently (and will likely remain) 2 distinct BAQs.

The first BAQ returns data with the QuoteDtl_QuoteNum field as key. I want to relate the second BAQ (the BAQDataView data) on QuoteNum as well, and then return a column from its data and meld them together in the grid.

I am having trouble getting the thing to work however.

Here is my dataview code:

private void CreateOrderBucketsView()
	{
		//Connects the BAQView to the EDV on Quote Num
		baqViewOrderBuckets = new BAQDataView("OPS_OrderBuckets");
		oTrans.Add("OrderBucketsBAQView", baqViewOrderBuckets);
		EpiDataView edvQ = (EpiDataView)oTrans.EpiDataViews["V_JRF_Quotes_1View"];
		string pub1Binding = edvQ.dataView[edvQ.Row]["QuoteDtl_QuoteNum"].ToString();
		IPublisher pub1 = oTrans.GetPublisher(pub1Binding);
		if(pub1==null)
		{
			string pubName = Guid.NewGuid().ToString();
			oTrans.PublishColumnChange(pub1Binding, pubName);
			pub1 = oTrans.GetPublisher(pub1Binding);
		}
		if(pub1!=null)
		{
			baqViewOrderBuckets.SubscribeToPublisher(pub1.PublishName, "QuoteHed_QuoteNum");
		}
	}

From my understanding, the pub1Binding variable stores the name of the column in another dataview that I will be relating the data from the BAQ on.

I tired calling this during the InitalizeCode(), but it fails to work, probably because there is no native dataview value to bind to.

Application Error

Exception caught in: mscorlib

Error Detail 
============
Message: Exception has been thrown by the target of an invocation.
Inner Exception Message: Index -1 is either negative or above rows count.
Program: CommonLanguageRuntimeLibrary
Method: InvokeMethod

Client Stack Trace 
==================
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Ice.Lib.Customization.CustomScriptMethodInvoker.InvokeScriptMethod(MethodInfo scriptMethod, Object[] parameters)
   at Ice.Lib.Customization.CustomScriptMethodInvoker.InvokeInitializeCustomCodeIfExists()
   at Ice.Lib.Customization.CustomScriptManager.TryActionShowExceptionBoxOrLogVerificationErrorIfException(Action action, String exceptionBoxTitle)

Inner Exception 
===============
Index -1 is either negative or above rows count.



   at System.Data.DataView.GetRow(Int32 index)
   at Script.CreateOrderBucketsView()
   at Script.InitializeCustomCode()

I’m sure I’m doing something wrong, but any guidance would be very much appreciated!

@Carson I used your code and watched your video, much appreciated by the way

I don’t have a definitive solution for you. But you could try replacing the line below. As you said, at initialization the view may not be loaded yet. Setting the value to a string might get around that.

string pub1Binding = "V_JRF_Quotes_1View.QuoteDtl_QuoteNum";

Also, make sure your BAQ OPS_OrderBuckets does not have any parameters defined. This has gotten me in the past.

Good luck! I am curious what solution you find!