BAQ DataView displays the first record, then never again

Hey there,

I have the following code connecting a BAQ to a grid in UD106:

public class Script
{
...
public void InitializeCustomCode()
{
private static BAQDataView _edvBAQQuoteOrderDisplay;
...

public void setQuoteOrderDisplayView()
{
	_edvBAQQuoteOrderDisplay = new BAQDataView ("TCF_ChangeOrderQOLookup"); // name of BAQ
	oTrans.Add("BAQQuoteOrderDisplayView", _edvBAQQuoteOrderDisplay); // creates dataview

	// publish 1
	string pubBinding = "UD106.Key1"; // publishes name in UD106 for dataview from BAQ
	IPublisher pub = oTrans.GetPublisher(pubBinding);

	if (pub == null)
	{
		oTrans.PublishColumnChange (pubBinding, "MyCustomPublish");
		pub = oTrans.GetPublisher (pubBinding);
	}

	if (pub != null) 
	{
		_edvBAQQuoteOrderDisplay.SubscribeToPublisher(pub.PublishName, "Calculated_TypeQuote"); // subscribes to UD106 dv based on baq type order
	}

	// publish 2
	pubBinding = "UD106.QuoteOrderNum_c";
	IPublisher pub2 = oTrans.GetPublisher(pubBinding);

	if(pub2==null)
	{
		oTrans.PublishColumnChange(pubBinding, "MyCustomPublish2");
		pub2 = oTrans.GetPublisher(pubBinding);
	}

	if(pub2 != null)
		_edvBAQQuoteOrderDisplay.SubscribeToPublisher(pub2.PublishName, "QuoteHed_QuoteNum");
}

The baq dataview is connected to a grid in the grid’s epibinding.

It works fine on the very first record loaded after opening the form. It displays data from the BAQ corresponding to the current data row.

But it never changes after that. It leaves the original record in the grid even when I navigate through the open record list in the tree or choose new records the search button.

If I clear the form or create a new record, the baq data stays displayed until I load a new record and then the grid is empty and never populates until I close and reopen the form.

I have a couple of baq dataviews like this in the form and they both show the same behavior.

I saw a piece of code originating from Jose Gomez and put this version of it in an epidataview notification:

(using System.Reflection;)

MethodInfo mi = _edvBAQQuoteOrderDisplay.GetType().GetMethod("invokeExecute", BindingFlags.Instance | BindingFlags.NonPublic); mi.Invoke(_edvBAQQuoteOrderDisplay, new object[]{ true });

It didn’t error, but didn’t refresh the baq dataview, either.

Any thoughts?

Thanks,

Joe

Update:

I was able to monkey with the publish/subscribe code to make the baq dataviews display the correct code for the record loaded, but when the form clears or (on a child record) there is no record, the last data in the baq dataview hangs around.

Here is a modified UD106A screen:

This parent record has no child line (no UD106A to subscribe to). The data shown here is hanging around from the first parent record in the list, which did have a child line.

Notice the button. It runs the following code:

	private void refreshBAQDataView(BAQDataView bdv)
	{
	    MethodInfo mi = bdv.GetType().GetMethod("invokeExecute", BindingFlags.Instance | BindingFlags.NonPublic);
	    mi.Invoke(bdv, new object[]{ true });
	}

	private void epiButtonC1_Click(object sender, System.EventArgs args)
	{
		refreshBAQDataView(_edvBAQPartDisplay);
	}

When I click the button “Retrieving Data…” briefly flashes in the status bar, but the old data either remains or is reloaded from the original record.

I’d gladly take a hint. :slight_smile:

Thanks,

Joe

If I am following this correctly you could just use something like this - basic example.

	private void edvUD106A_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
	{
		// ** Argument Properties and Uses **
		// view.dataView[args.Row]["FieldName"]
		// args.Row, args.Column, args.Sender, args.NotifyType
		// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
		if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
		{
			if ((args.Row > -1))
			{
			}
			else
			{
				_edvBAQQuoteOrderDisplay.dataView.Table.Clear();
			}
		}
	}
1 Like

That’s my missing piece.

Thanks, Dan.

Joe