# Refresh EpiUltraGrid BAQ dataview when a new line is added

**URL:** <https://www.epiusers.help/t/refresh-epiultragrid-baq-dataview-when-a-new-line-is-added/81082>\
**Category:** Epicor ERP 10\
**Tags:** customization, baq-dataview\
**Created:** [July 29, 2021, 9:39pm UTC](https://www.epiusers.help/t/refresh-epiultragrid-baq-dataview-when-a-new-line-is-added/81082 "2021-07-29T21:39:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mriannejoy](https://www.epiusers.help/letter_avatar_proxy/v4/letter/m/dfb087/32.png) [@mriannejoy](https://www.epiusers.help/u/mriannejoy)\
**Post date:** [July 29, 2021, 9:39pm UTC](https://www.epiusers.help/t/refresh-epiultragrid-baq-dataview-when-a-new-line-is-added/81082/1 "2021-07-29T21:39:10Z")

</div>

Hello everyone,

I have created my first BAQ Dataview in our quote form and it is all working really well. Thanks to this forum. So, I have created 3 BAQ dataview. And now I am wanting to have this baqs refresh when a new line is added. I have seen @josecgomez ’ solution from other topics but I could not make it work. Any help will be very much appreciated.  
Here’s my code

```auto

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Ice.Lib.Broadcast;
using System.Reflection;

public class Script
{
	// **Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments!**
	// Begin Wizard Added Module Level Variables **
	// End Wizard Added Module Level Variables **
	// Add Custom Module Level Variables Here **

	BAQDataView QuoteMTLPriceListBAQDV;
	BAQDataView MTLLabourCostBAQDV;
	BAQDataView QuoteMarkUpBAQDV;

	public void InitializeCustomCode()
	{
		// **Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines**
		// Begin Wizard Added Variable Initialization
		// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
		// End Wizard Added Custom Method Calls
	CreateQuoteMTLPriceListBAQview();
	CreateMTLLabourCostBAQview();
	CreateQuoteMarkUpBAQview();

	}

public void CreateQuoteMTLPriceListBAQview() {
        QuoteMTLPriceListBAQDV = new BAQDataView("QuoteMTLPriceList");
        oTrans.Add("QuoteMaterialsPricelist", QuoteMTLPriceListBAQDV);
        string pub1Binding = "QuoteHed.QuoteNum";
        IPublisher pub1 = oTrans.GetPublisher(pub1Binding);
        if (pub1 == null) 
        {
            string pubName = Guid.NewGuid().ToString();
            oTrans.PublishColumnChange(pub1Binding, pubName);
            pub1 = oTrans.GetPublisher(pub1Binding);
        }
        if (pub1 != null)
            QuoteMTLPriceListBAQDV .SubscribeToPublisher(pub1.PublishName, "QuoteDtl1_QuoteNum");

string pub2Binding = "QuoteDtl.QuoteLine";
        IPublisher pub2 = oTrans.GetPublisher(pub2Binding);
        if (pub2 == null) 
        {
            string pubName = Guid.NewGuid().ToString();
            oTrans.PublishColumnChange(pub2Binding, pubName);
            pub2 = oTrans.GetPublisher(pub2Binding);
        }
        if (pub2 != null)
            QuoteMTLPriceListBAQDV .SubscribeToPublisher(pub2.PublishName, "QuoteDtl1_QuoteLine");}
	
public void CreateMTLLabourCostBAQview() {

        MTLLabourCostBAQDV = new BAQDataView("ICQuoteMTLCost");
        oTrans.Add("MaterialLabourCost", MTLLabourCostBAQDV);

        string pub1Binding = "QuoteHed.QuoteNum";
        IPublisher pub1 = oTrans.GetPublisher(pub1Binding);
        if (pub1 == null) 
        {
            string pubName = Guid.NewGuid().ToString();
            oTrans.PublishColumnChange(pub1Binding, pubName);
            pub1 = oTrans.GetPublisher(pub1Binding);
        }
        if (pub1 != null)
            MTLLabourCostBAQDV .SubscribeToPublisher(pub1.PublishName, "QuoteDtl1_QuoteNum");

		string pub2Binding = "QuoteDtl.QuoteLine";
        IPublisher pub2 = oTrans.GetPublisher(pub2Binding);
        if (pub2 == null) {
            string pubName = Guid.NewGuid().ToString();
            oTrans.PublishColumnChange(pub2Binding, pubName);
            pub2 = oTrans.GetPublisher(pub2Binding); }
        if (pub2 != null)
            MTLLabourCostBAQDV .SubscribeToPublisher(pub2.PublishName, "QuoteDtl1_QuoteLine");}
	public void CreateQuoteMarkUpBAQview()
    {
       QuoteMarkUpBAQDV = new BAQDataView("QuotePricelist");
        oTrans.Add("MarkUp", QuoteMarkUpBAQDV);

        string pub1Binding = "QuoteHed.QuoteNum";
        IPublisher pub1 = oTrans.GetPublisher(pub1Binding);
        if (pub1 == null) 
        {
            string pubName = Guid.NewGuid().ToString();
            oTrans.PublishColumnChange(pub1Binding, pubName);
            pub1 = oTrans.GetPublisher(pub1Binding);
        }
        if (pub1 != null)
            QuoteMarkUpBAQDV .SubscribeToPublisher(pub1.PublishName, "QuoteDtl_QuoteNum");

string pub2Binding = "QuoteDtl.QuoteLine";
        IPublisher pub2 = oTrans.GetPublisher(pub2Binding);
        if (pub2 == null) 
        {
            string pubName = Guid.NewGuid().ToString();
            oTrans.PublishColumnChange(pub2Binding, pubName);
            pub2 = oTrans.GetPublisher(pub2Binding);
        }
        if (pub2 != null)
            QuoteMarkUpBAQDV .SubscribeToPublisher(pub2.PublishName, "QuoteDtl_QuoteLine");
}
	public void DestroyCustomCode()
	{
		// **Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines**
		// Begin Wizard Added Object Disposal
		// End Wizard Added Object Disposal
		// Begin Custom Code Disposal
		// End Custom Code Disposal
	})

```

---

<div class="post-metadata">

**Author:** ![bordway](https://www.epiusers.help/user_avatar/www.epiusers.help/bordway/32/30753_2.png) [@bordway](https://www.epiusers.help/u/bordway)\
**Post date:** [August 1, 2021, 5:28pm UTC](https://www.epiusers.help/t/refresh-epiultragrid-baq-dataview-when-a-new-line-is-added/81082/2 "2021-08-01T17:28:10Z")

</div>

Have you already tried the example in the thread below

- [BAQ Dataview Example Video - #14 by Carson](https://www.epiusers.help/t/baq-dataview-example-video/70295/14)
- per Carson Ripple, looking for changes via an EpiViewNotification?

---

<div class="post-metadata">

**Author:** ![mriannejoy](https://www.epiusers.help/letter_avatar_proxy/v4/letter/m/dfb087/32.png) [@mriannejoy](https://www.epiusers.help/u/mriannejoy)\
**Post date:** [August 1, 2021, 8:47pm UTC](https://www.epiusers.help/t/refresh-epiultragrid-baq-dataview-when-a-new-line-is-added/81082/3 "2021-08-01T20:47:11Z")

</div>

I tried adding the EpiViewNotification but it seems to be not working as well.  
My BAq dv only refreshed once I clear my form and open the quote again.

---

<div class="post-metadata">

**Author:** ![mriannejoy](https://www.epiusers.help/letter_avatar_proxy/v4/letter/m/dfb087/32.png) [@mriannejoy](https://www.epiusers.help/u/mriannejoy)\
**Post date:** [August 1, 2021, 8:48pm UTC](https://www.epiusers.help/t/refresh-epiultragrid-baq-dataview-when-a-new-line-is-added/81082/4 "2021-08-01T20:48:14Z")

</div>

@josecgomez could you please help me on this? I see topics like this that your code works. I tried addin it in mine but it just don’t work at all. I might be missing something…

I sort of making it work by adding an epiButton and pasting your code. 🙂  
I followed this [Epi button to refresh embedded BAQ - #2 by jorel](https://www.epiusers.help/t/epi-button-to-refresh-embedded-baq/70601/2)  
But it would really be amazing if I could find a way of refreshing the BAQDV without the epibutton.

---

<div class="post-metadata">

**Author:** ![jgiese.wci](https://www.epiusers.help/user_avatar/www.epiusers.help/jgiese.wci/32/51553_2.png) [@jgiese.wci](https://www.epiusers.help/u/jgiese.wci)\
**Post date:** [August 2, 2021, 1:29pm UTC](https://www.epiusers.help/t/refresh-epiultragrid-baq-dataview-when-a-new-line-is-added/81082/5 "2021-08-02T13:29:09Z")

</div>

Please make sure you format your code in posts [Code Syntax Highlighting in Posts](https://www.epiusers.help/t/code-syntax-highlighting-in-posts/33519)

Where is your event code for refreshing. Do you want it to refresh after you save the line or before the line is added to be edited? If you are using an Updatable BAQ you need a lot more code to get that all done.

---

<div class="post-metadata">

**Author:** ![bordway](https://www.epiusers.help/user_avatar/www.epiusers.help/bordway/32/30753_2.png) [@bordway](https://www.epiusers.help/u/bordway)\
**Post date:** [August 2, 2021, 3:08pm UTC](https://www.epiusers.help/t/refresh-epiultragrid-baq-dataview-when-a-new-line-is-added/81082/6 "2021-08-02T15:08:19Z")

</div>

> [@mriannejoy](#):
>
> I tried adding the EpiViewNotification

I didn’t notice an EpiDataView notification in your code example - maybe you can post your latest attempt at the EpiDataView notification?

---

<div class="post-metadata">

**Author:** ![mriannejoy](https://www.epiusers.help/letter_avatar_proxy/v4/letter/m/dfb087/32.png) [@mriannejoy](https://www.epiusers.help/u/mriannejoy)\
**Post date:** [August 2, 2021, 9:16pm UTC](https://www.epiusers.help/t/refresh-epiultragrid-baq-dataview-when-a-new-line-is-added/81082/7 "2021-08-02T21:16:49Z")

</div>

Thanks for the link. It’s my first time posting a code. I’ll know next time. 🙂

I sort of making it work now. I have added an EpiButton to refresh the BAQdv which works with my boss. It is my first time working with customization and Epicor in general so I’ll leave it that way for now while I’m still learning the coding stuff and all. Thank you for your inputs, appreciate it.

---

<div class="post-metadata">

**Author:** ![mriannejoy](https://www.epiusers.help/letter_avatar_proxy/v4/letter/m/dfb087/32.png) [@mriannejoy](https://www.epiusers.help/u/mriannejoy)\
**Post date:** [August 2, 2021, 9:19pm UTC](https://www.epiusers.help/t/refresh-epiultragrid-baq-dataview-when-a-new-line-is-added/81082/8 "2021-08-02T21:19:59Z")

</div>

Oh, I was not able to post the code with the EpiDataView notification. I added an EpiButton instead to refresh which works for now. I might need to read Epicor guides for now so I know when to use this. Thanks for your help, appreciate it.
