Epi button to refresh embedded BAQ

Hi, hoping someone can help as have seen various posts on this but have had no luck myself.

I have created a BAQ view within Customer Tracker and have binded this to the existing grid for open invoices. The data populates as I would expect however I am unable to refresh this data when there is an updated record. (the BAQ is not updatable)

I have tried to use the original retrieve button pubbinding to the original gird which would be InvOpen.Custnum, with the publishName Customer_Custnum but this does not retrieve any data at all…

	public void CreateCustomAllBAQView()
{
               //add BAQDataView to current transaction
               baqCustomAll = new BAQDataView("InvoiceHedCustTracker");
               oTrans.Add("CustomInvHdr", baqCustomAll);
 
               //publish a binding to Customer.CustID
               string pubBinding = "InvOpen.CustNum";
               IPublisher pub = oTrans.GetPublisher(pubBinding);
               if(pub==null)
               {
                              oTrans.PublishColumnChange(pubBinding, "CustomPublish");
                              pub = oTrans.GetPublisher(pubBinding);
               }
 
               //subscribe the Customer_CustID field in the BAQDataView to the published binding
               if(pub !=null)
               {
                              baqCustomAll.SubscribeToPublisher(pub.PublishName, "Customer_CustNum");
               }
}```

I have tried adding an epibutton through event wizard but ive no idea how to refresh. Any help would be much appreciated. 

Hope the above makes sense.

```// **************************************************
// Custom code for CustomerTrackerForm
// Created: 11/10/2017 14:00:32
// **************************************************

extern alias Erp_Contracts_BO_Customer;
extern alias Erp_Contracts_BO_CreditManager;
extern alias Erp_Contracts_BO_ARInvoice;
extern alias Erp_Contracts_BO_Quote;
extern alias Erp_Contracts_BO_CustCnt;
extern alias Erp_Contracts_BO_ARLOC;
extern alias Erp_Contracts_BO_CashDtlSearch;
extern alias Erp_Contracts_BO_ServiceContract;
extern alias Erp_Contracts_BO_CustShip;
extern alias Erp_Contracts_BO_CashRecSearch;
extern alias Erp_Contracts_BO_ARPromissoryNotes;
extern alias Erp_Contracts_BO_SalesOrdHedDtl;
extern alias Erp_Contracts_BO_OrderDtlSearch;
extern alias Erp_Contracts_BO_ShipDtlSearch;

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 Infragistics.Win;
using Infragistics.Win.UltraWinGrid;

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 baqCustomAll;
	BAQDataView baqCustomAllV1;
	
	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
		CreateCustomAllBAQView();
		CreateCustomAllV1BAQView();
		CreateRowRuleCustomInvHdrHDCase2_HDCaseStatusContains_CLOSED();;
		CreateRowRuleCustomInvHdrV1HDCase2_HDCaseStatusContains_OPEN();;
		CreateRowRuleCustomInvHdrV1HDCase2_HDCaseStatusContains_CLOSED();;
		CreateRowRuleCustomInvHdrHDCase2_HDCaseStatusContains_OPEN();
		this.RefreshBtn.Click += new System.EventHandler(this.RefreshBtn_Click);
		// End Wizard Added Custom Method Calls


	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal
		this.RefreshBtn.Click -= new System.EventHandler(this.RefreshBtn_Click);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void CustomerTrackerForm_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code
		EpiBasePanel detailPanel1;
		detailPanel1 = (EpiBasePanel)(csm.GetNativeControlReference("8fd5b1fa-db9e-423c-baca-4656696c859b"));
		detailPanel1.Focus();
	}



	public void CreateCustomAllBAQView()
{
               //add BAQDataView to current transaction
               baqCustomAll = new BAQDataView("InvoiceHedCustTracker");
               oTrans.Add("CustomInvHdr", baqCustomAll);
 
               //publish a binding to Customer.CustID
               string pubBinding = "InvOpen.CustNum";
               IPublisher pub = oTrans.GetPublisher(pubBinding);
               if(pub==null)
               {
                              oTrans.PublishColumnChange(pubBinding, "CustomPublish");
                              pub = oTrans.GetPublisher(pubBinding);
               }
 
               //subscribe the Customer_CustID field in the BAQDataView to the published binding
               if(pub !=null)
               {
                              baqCustomAll.SubscribeToPublisher(pub.PublishName, "Customer_CustNum");
               }
}

	public void CreateCustomAllV1BAQView()
{
               //add BAQDataView to current transaction
               baqCustomAllV1 = new BAQDataView("InvoiceHedCustTracker(closed)");
               oTrans.Add("CustomInvHdrV1", baqCustomAllV1);
 
               //publish a binding to Customer.CustID
               string pubBinding = "Customer.CustID";
               IPublisher pub = oTrans.GetPublisher(pubBinding);
               if(pub==null)
               {
                              oTrans.PublishColumnChange(pubBinding, "CustomPublishV1");
                              pub = oTrans.GetPublisher(pubBinding);
               }
 
               //subscribe the Customer_CustID field in the BAQDataView to the published binding
               if(pub !=null)
               {
                              baqCustomAllV1.SubscribeToPublisher(pub.PublishName, "Customer_CustID");
               }
}
	


	private void CreateRowRuleCustomInvHdrHDCase2_HDCaseStatusContains_CLOSED()
	{
		// Description: Open Invoices
		// **** begin autogenerated code ****
		ControlSettings myControlSettings = new ControlSettings();
		myControlSettings.BackColor = System.Drawing.Color.LightGreen;
		RuleAction okCustomInvHdr_RowAction = RuleAction.AddRowSettings(this.oTrans, "CustomInvHdr", false,myControlSettings);
		RuleAction[] ruleActions = new RuleAction[] {
				okCustomInvHdr_RowAction};
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleCustomInvHdrHDCase2_HDCaseStatusContains_CLOSED = new RowRule("CustomInvHdr.HDCase2_HDCaseStatus", RuleCondition.Contains, "CLOSED", ruleActions);
		((EpiDataView)(this.oTrans.EpiDataViews["CustomInvHdr"])).AddRowRule(rrCreateRowRuleCustomInvHdrHDCase2_HDCaseStatusContains_CLOSED);
		// **** end autogenerated code ****
	}



	private void CreateRowRuleCustomInvHdrV1HDCase2_HDCaseStatusContains_OPEN()
	{
		// Description: Closed Invoices
		// **** begin autogenerated code ****
		RuleAction errorCustomInvHdrV1_RowAction = RuleAction.AddRowSettings(this.oTrans, "CustomInvHdrV1", false, SettingStyle.Error);
		RuleAction[] ruleActions = new RuleAction[] {
				errorCustomInvHdrV1_RowAction};
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleCustomInvHdrV1HDCase2_HDCaseStatusContains_OPEN = new RowRule("CustomInvHdrV1.HDCase2_HDCaseStatus", RuleCondition.Contains, "OPEN", ruleActions);
		((EpiDataView)(this.oTrans.EpiDataViews["CustomInvHdrV1"])).AddRowRule(rrCreateRowRuleCustomInvHdrV1HDCase2_HDCaseStatusContains_OPEN);
		// **** end autogenerated code ****
	}





	private void CreateRowRuleCustomInvHdrV1HDCase2_HDCaseStatusContains_CLOSED()
	{
		// Description: Closed Invoices
		// **** begin autogenerated code ****
		ControlSettings myControlSettings = new ControlSettings();
		myControlSettings.BackColor = System.Drawing.Color.LightGreen;
		RuleAction okCustomInvHdrV1_RowAction = RuleAction.AddRowSettings(this.oTrans, "CustomInvHdrV1", false, myControlSettings);
		RuleAction[] ruleActions = new RuleAction[] {
				okCustomInvHdrV1_RowAction};
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleCustomInvHdrV1HDCase2_HDCaseStatusContains_CLOSED = new RowRule("CustomInvHdrV1.HDCase2_HDCaseStatus", RuleCondition.Contains, "CLOSED", ruleActions);
		((EpiDataView)(this.oTrans.EpiDataViews["CustomInvHdrV1"])).AddRowRule(rrCreateRowRuleCustomInvHdrV1HDCase2_HDCaseStatusContains_CLOSED);
		// **** end autogenerated code ****
	}




	private void CreateRowRuleCustomInvHdrHDCase2_HDCaseStatusContains_OPEN()
	{
		// Description: OpenInv
		// **** begin autogenerated code ****
		RuleAction errorCustomInvHdr_RowAction = RuleAction.AddRowSettings(this.oTrans, "CustomInvHdr", false, SettingStyle.Error);
		RuleAction[] ruleActions = new RuleAction[] {
				errorCustomInvHdr_RowAction};
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleCustomInvHdrHDCase2_HDCaseStatusContains_OPEN = new RowRule("CustomInvHdr.HDCase2_HDCaseStatus", RuleCondition.Contains, "OPEN", ruleActions);
		((EpiDataView)(this.oTrans.EpiDataViews["CustomInvHdr"])).AddRowRule(rrCreateRowRuleCustomInvHdrHDCase2_HDCaseStatusContains_OPEN);
		// **** end autogenerated code ****
	}



	private void RefreshBtn_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
	//MessageBox.Show("Click");
	oTrans.Refresh();
			
	}
}

Place an epibutton on the form. Then use the Event Wizards to the button click event like so…
image
In the event handling code section, insert the code Jose provided in the above post. (Make sure you change the baqDataView to yours). Also make sure you add the “using” statement to the top.

1 Like

Hi, thank you for your help on this, this has worked :slight_smile:

1 Like