Refresh EpiUltraGrid BAQ dataview when a new line is added

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


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
	})

Have you already tried the example in the thread below

1 Like

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.

@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. :slight_smile:
I followed this Epi button to refresh embedded BAQ - #2 by jorel
But it would really be amazing if I could find a way of refreshing the BAQDV without the epibutton.

Please make sure you format your code in posts Code Syntax Highlighting in Posts

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.

2 Likes

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

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

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.

1 Like

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.

1 Like