# BAQ Data View

**URL:** <https://www.epiusers.help/t/baq-data-view/49948>\
**Category:** Epicor ERP 10\
**Tags:** customization\
**Created:** [November 21, 2018, 2:30pm UTC](https://www.epiusers.help/t/baq-data-view/49948 "2018-11-21T14:30:41Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![skearney](https://www.epiusers.help/user_avatar/www.epiusers.help/skearney/32/11498_2.png) [@skearney](https://www.epiusers.help/u/skearney)\
**Post date:** [November 21, 2018, 2:30pm UTC](https://www.epiusers.help/t/baq-data-view/49948/1 "2018-11-21T14:30:41Z")

</div>

I have created a BAQ Data View that I would like to be able to subscribe to a text box in my Dashboard. This is just a free form text box that when a customer ID is entered into it the BAQ Data View will subscribe to it and reset the DataView. @josecgomez helped me with the Data View.

```auto
		//Customer - Customer Data View
private void CreateCustomerBAQView() 
	{
	GS_Customer_DataView = new BAQDataView("GS_Customer_DataView");
	oTrans.Add("GS_Customer_DataView", GS_Customer_DataView);
	var CustID = tbCustomerIDRef.Text.ToString(); //This is where I need it to subscribe to text box - this doesn't seem to work. 
	oTrans.PublishColumnChange(CustID, Guid.NewGuid().ToString());
	var CustIDPub = oTrans.GetPublisher(CustID);
	GS_Customer_DataView.SubscribeToPublisher(CustIDPub.PublishName, "Customer_CustID");
	}	 

```

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [November 21, 2018, 2:41pm UTC](https://www.epiusers.help/t/baq-data-view/49948/2 "2018-11-21T14:41:41Z")

</div>

So to do that you’ll have to create a DataView and bind that to your TextBox. Try this

```cs
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("CustID",typeof(string));
dt.Columns.Add(new DataColumn("SysRowID",typeof(Guid));
var r = dt.NewRow();
dt.Rows.Add(r);
EpiDataView edvMyCustomDV = new EpiDataView();
edvMyCustomDV.dataView = dt.DefaultView;
oTrans.Add("MyCustomView",edvMyCustomDV);

```

Once this runs for the first time (in initilize custom code) you should have a new data view in your dashboard called MyCustomView which you can bind to your TextBox. Then you can use the Publish Subscribe code above to publish changes tol your new cust ID field as

```cs
var CustID = "MyCustomView.CustID"; //This is where I need it to subscribe to text box - this doesn't seem to work.
```

---

<div class="post-metadata">

**Author:** ![skearney](https://www.epiusers.help/user_avatar/www.epiusers.help/skearney/32/11498_2.png) [@skearney](https://www.epiusers.help/u/skearney)\
**Post date:** [November 21, 2018, 3:03pm UTC](https://www.epiusers.help/t/baq-data-view/49948/3 "2018-11-21T15:03:30Z")

</div>

> [@josecgomez](#):
>
> var CustID = “MyCustomView.CustID”;

```auto
		//Customer - Customer Data View
private void CreateCustomerBAQView() 
	{
	GS_Customer_DataView = new BAQDataView("GS_Customer_DataView");
	oTrans.Add("GS_Customer_DataView", GS_Customer_DataView);
	var CustID = "MyCustomView.CustID";
	oTrans.PublishColumnChange(CustID, Guid.NewGuid().ToString());
	var CustIDPub = oTrans.GetPublisher(CustID);
	GS_Customer_DataView.SubscribeToPublisher(CustIDPub.PublishName, "Customer_CustID");
	}	

//Customer - Make DataView for Publishing
	private void CustomerPublisherView()
	{
	DataTable dt = new DataTable();
	dt.Columns.Add(new DataColumn("CustID",typeof(string)));
	dt.Columns.Add(new DataColumn("SysRowID",typeof(Guid)));
	var r = dt.NewRow();
	dt.Rows.Add(r);
	EpiDataView edvMyCustomDV = new EpiDataView();
	edvMyCustomDV.dataView = dt.DefaultView;
	oTrans.Add("MyCustomView",edvMyCustomDV);
	}
		
//Customer - Refresh Data View
	private void RefreshCustomerDataView()
	{
		MethodInfo mi = GS_Customer_DataView.GetType().GetMethod("invokeExecute", BindingFlags.Instance | BindingFlags.NonPublic);
		mi.Invoke(GS_Customer_DataView, new object[]{ true });
	}
	
	//Customer - On Leave Refreshes the View and Grids
	private void tbCustomerIDRef_Leave(object sender, System.EventArgs args)
		{
		if (tbCustomerIDRef.Text.Length >= 3)
		{
			RefreshCustomerDataView();
		}
			else
			{
			}
		}

```

---

<div class="post-metadata">

**Author:** ![skearney](https://www.epiusers.help/user_avatar/www.epiusers.help/skearney/32/11498_2.png) [@skearney](https://www.epiusers.help/u/skearney)\
**Post date:** [November 21, 2018, 3:04pm UTC](https://www.epiusers.help/t/baq-data-view/49948/4 "2018-11-21T15:04:44Z")

</div>

Okay something isn’t right. The Data View is showing up. I bound the text box to the new data view. Then when I enter a valid customer number and leave the box I have it setup to reset the data view. It is resetting the data view but it is just finding the first record and not the matching record in the BAQ Data View.

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [November 21, 2018, 3:05pm UTC](https://www.epiusers.help/t/baq-data-view/49948/5 "2018-11-21T15:05:29Z")

</div>

Are you adding the new view before your BAQ View? (Order matters)  
By the way you shouldn’t have to force it to refresh the publish / subscribe should take care of that for you

---

<div class="post-metadata">

**Author:** ![skearney](https://www.epiusers.help/user_avatar/www.epiusers.help/skearney/32/11498_2.png) [@skearney](https://www.epiusers.help/u/skearney)\
**Post date:** [November 21, 2018, 3:10pm UTC](https://www.epiusers.help/t/baq-data-view/49948/6 "2018-11-21T15:10:33Z")

</div>

It is in the correct order now and working perfectly. I also removed the on leave refresh and that is working perfectly! Thank you so much as always. I really like these BAQ Data View’s vs. using a Dashboard, they seem so much faster and elegant!

---

<div class="post-metadata">

**Author:** ![skearney](https://www.epiusers.help/user_avatar/www.epiusers.help/skearney/32/11498_2.png) [@skearney](https://www.epiusers.help/u/skearney)\
**Post date:** [November 21, 2018, 7:41pm UTC](https://www.epiusers.help/t/baq-data-view/49948/7 "2018-11-21T19:41:59Z")

</div>

Okay one more question. I have a search which populates this text box with a Customer ID. How can I get the view to refresh without the user having to tab out of the box

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [November 21, 2018, 7:44pm UTC](https://www.epiusers.help/t/baq-data-view/49948/8 "2018-11-21T19:44:11Z")

</div>

How are you invoking the search? Button Click? If so populate teh DataView not the TextBox.

```cs
myCustomDV.dataView[myCustomDV.Row].BeginEdit();
myCustomDV.dataView[myCustomDV.Row]["CustID"]=YourSearchResults
myCustomDV.dataView[myCustomDV.Row].EndEdit();

```

---

<div class="post-metadata">

**Author:** ![skearney](https://www.epiusers.help/user_avatar/www.epiusers.help/skearney/32/11498_2.png) [@skearney](https://www.epiusers.help/u/skearney)\
**Post date:** [November 21, 2018, 8:00pm UTC](https://www.epiusers.help/t/baq-data-view/49948/9 "2018-11-21T20:00:14Z")

</div>

I am invoking the search with a button click.

Okay I put that in my Search Adapter Section:

```auto
	private void SearchOnCustomerAdapterShowDialog_1()
	{
		 //Wizard Generated Search Method
		 //You will need to call this method from another method in custom code
		 //For example, [Form]_Load or [Button]_Click

		bool recSelected;
		string whereClause = string.Empty;
		System.Data.DataSet dsCustomerAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "CustomerAdapter", out recSelected, true, whereClause);
		if (recSelected)
		{
			System.Data.DataRow adapterRow = dsCustomerAdapter.Tables[0].Rows[0];
			tbCustomerIDRef.Text = adapterRow["CustID"].ToString();
			myCustomDV.dataView[myCustomDV.Row].BeginEdit();
			myCustomDV.dataView[myCustomDV.Row]["CustID"]=tbCustomerIDRef.Text;
			myCustomDV.dataView[myCustomDV.Row].EndEdit();
			changecustomernumber();			
		}
	}

```

I get the error the name “myCustomDV” does not exist in the current context.

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [November 21, 2018, 8:03pm UTC](https://www.epiusers.help/t/baq-data-view/49948/10 "2018-11-21T20:03:35Z")

</div>

Well sorry I’m not sure what the name of your custom DV try this

```cs
var myCustomDV = oTrans.Factory("MyCustomView");

```

then the rest of the code

---

<div class="post-metadata">

**Author:** ![skearney](https://www.epiusers.help/user_avatar/www.epiusers.help/skearney/32/11498_2.png) [@skearney](https://www.epiusers.help/u/skearney)\
**Post date:** [November 21, 2018, 8:04pm UTC](https://www.epiusers.help/t/baq-data-view/49948/11 "2018-11-21T20:04:45Z")

</div>

Oh sorry, It was the Data View you were helping me with earlier.

````auto
//Customer - Make DataView for Publishing
	private void CustomerPublisherView()
	{
	DataTable dt = new DataTable();
	dt.Columns.Add(new DataColumn("CustID",typeof(string)));
	dt.Columns.Add(new DataColumn("SysRowID",typeof(Guid)));
	var r = dt.NewRow();
	dt.Rows.Add(r);
	EpiDataView edvMyCustomDV = new EpiDataView();
	edvMyCustomDV.dataView = dt.DefaultView;
	oTrans.Add("MyCustomView",edvMyCustomDV);
	}```
````

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [November 21, 2018, 8:06pm UTC](https://www.epiusers.help/t/baq-data-view/49948/12 "2018-11-21T20:06:04Z")

</div>

Right try the option above

---

<div class="post-metadata">

**Author:** ![skearney](https://www.epiusers.help/user_avatar/www.epiusers.help/skearney/32/11498_2.png) [@skearney](https://www.epiusers.help/u/skearney)\
**Post date:** [November 21, 2018, 8:12pm UTC](https://www.epiusers.help/t/baq-data-view/49948/13 "2018-11-21T20:12:25Z")

</div>

Perfect! That worked Thank you!

---

<div class="post-metadata">

**Author:** ![skearney](https://www.epiusers.help/user_avatar/www.epiusers.help/skearney/32/11498_2.png) [@skearney](https://www.epiusers.help/u/skearney)\
**Post date:** [November 28, 2018, 7:29pm UTC](https://www.epiusers.help/t/baq-data-view/49948/14 "2018-11-28T19:29:08Z")

</div>

Any thoughts on why an updatable dashboard that I am having subscribe to the Order Data View wouldn’t be working? It doesn’t respond when I enter an order number?
