BAQ Dataview Example Video

My first guess as to the cause of your problem was that ShipToNum can be blank. In fact, I think when a Customer record is first created, a ShipTo record with a blank SipToNum will be created. If it’s not when the customer is first created, then it might be when the first ShipTo (which becomes the second ShipTo record for the customer) is created.

Does you BAQ handle that condition okay?

1 Like

It works fine with the blank shipto records and correctly returns the data for the blank shipto record. The one that I dug completely the BAQ dataview appeared to have only filtered on the CustNum and not the ship to. While debugging I could see the publisher was correctly publishing the shipTo in oTrans, but the BAQ had returned all the records for that customer and did not filter the ship to even thought there was a matching shipto record in the dataview. Changing the shipto and changing it back would correctly refresh the BAQ Dataview. I only saw the issue when loading multiple records at once and using the record select arrows to move between records.

Hi. I am trying to replace the grid in Opportunity/Quote Entry > Line > Manufacturing > Details > Quote Details > Materials > List with a BAQ Data View. Reason being we want to see fields like QtyOnHand and several other fields from different tables for each part in the current quote. Following from the advice in this post I have created a BAQ and managed the below code.

Problem is the list view is now showing me a list of quotes just the one part is in. I need all the parts showing. This must have something to do with needing to filter by the QuoteHed.QuoteNum?

Any help much appreciated - I’m a beginner!
Thanks

using Ice.Lib.Broadcast;

public class Script
{

BAQDataView baqViewMatGrid;

public void InitializeCustomCode()
{
	
	CreateMatGridBAQView();
}

public void CreateMatGridBAQView()
{
	baqViewMatGrid = new BAQDataView ("JSL-QuoteMtlOnHandBAQView");
	oTrans.Add("MaterialsGridBAQ",baqViewMatGrid);

	string pubBinding = "JobMtl.PartNum";
	IPublisher pub = oTrans.GetPublisher(pubBinding);
	if(pub==null)
		{
			string pubName = Guid.NewGuid().ToString();
			oTrans.PublishColumnChange(pubBinding, "MyCustomerPublishMatGrid");
			pub = oTrans.GetPublisher(pubBinding);
		}

	if(pub !=null)
		baqViewMatGrid.SubscribeToPublisher(pub.PublishName,"QuoteMtl_PartNum");
}

This is great! Thank you so much for sharing! I am trying to implement this solution on a custom dashboard. How do I know which values to enter for pub1Binding? You can see I am trying to link to text box values and combo box values.

public void CreateEcoRevOpsBAQDV()
	{

		ecoRevOpsBAQDV = new BAQDataView("getPartRevOpECO"); //baq name
		oTrans.Add("EcoRevOpsBAQDV",ecoRevOpsBAQDV); 
		string pub1Binding = "txtMyPart.Text"; //Native form linking field 1
		IPublisher pub1 = oTrans.GetPublisher(pub1Binding);
		if(pub1==null) 
		{ 
			string pubName = Guid.NewGuid().ToString();
			oTrans.PublishColumnChange(pub1Binding, pubName);
			pub1 = oTrans.GetPublisher(pub1Binding);
		} 
		if(pub1 !=null) 
			ecoRevOpsBAQDV.SubscribeToPublisher(pub1.PublishName, "ECORev_PartNum"); //BAQ linking field 1

		string pub2Binding = "revCombo.Text"; //Native form linking field 2
		IPublisher pub2 = oTrans.GetPublisher(pub2Binding);
		if(pub2==null) 
		{ 
			string pubName = Guid.NewGuid().ToString();
			oTrans.PublishColumnChange(pub2Binding, pubName);
			pub2 = oTrans.GetPublisher(pub2Binding);
		} 
		if(pub2 !=null) 
			ecoRevOpsBAQDV.SubscribeToPublisher(pub2.PublishName, "ECORev_RevisionNum");//BAQ linking field 2



	}

It is the name of the DataView/Field where the values come from. So lookk at your grid and see what EpiBinding and use that plus the field name.

1 Like

Perfect! I had to switch mine to “V_EditAnyOp_1View.PartRev_PartNum”. I also forgot to remove the parameters from my BAQ. I had removed the criteria but left the parameters. Once I removed them and fixed the syntax, this works great! Thanks for the help!

2 Likes

I am trying to use this bit of code to manually refresh my BAQDataView:

private void CheckForCheckedOut(BAQDataView myBAQDV)
	{
		if (myBAQDV.dataView.Count > 0)
		{
			//MessageBox.Show("Checked Out!");
			ecoUltraGrid.Visible=true;
			lblCheckedOutWarning.Visible = true;
			MethodInfo mi = myBAQDV.GetType().GetMethod("invokeExecute", BindingFlags.Instance | BindingFlags.NonPublic);
   		 mi.Invoke(myBAQDV , new object[]{ true });
		}
		else
		{
			ecoUltraGrid.Visible=false;
			lblCheckedOutWarning.Visible = false;
		}
	}

This bit of code is called anytime a relevant field is changed (ValueChanged). But I keep getting an error on the methodinfo bit that is supposed to refresh my BAQ View.

Application Error

Exception caught in: App.EditAnyOp.MainController.EP.VTAERO.Customization.Custom2.CustomCode.59

Error Detail 
============
Message: Object reference not set to an instance of an object.
Program: App.EditAnyOp.MainController.EP.VTAERO.Customization.Custom2.CustomCode.59.dll
Method: CheckForCheckedOut

Client Stack Trace 
==================
   at Script.CheckForCheckedOut(BAQDataView myBAQDV)
   at Script.V_EditAnyOp_1View_AfterRowChange(EpiRowChangedArgs args)
   at Ice.Lib.Framework.EpiRowChanged.Invoke(EpiRowChangedArgs args)
   at Ice.Lib.Framework.EpiDataView.RaiseRowChanged(Int32 currentRow, Int32 lastRow)
   at Ice.Lib.Framework.EpiDataView.onRowChanged(Int32 currentRow, Int32 lastRow)
   at Ice.Lib.Framework.EpiDataView.SetCurrentRow(Int32 newRow, Boolean currentRowOnly)
   at Ice.Lib.Framework.EpiUltraGrid.OnBeforeCellActivated(Object sender, CancelableCellEventArgs ea)

I am using reflection. Is there something else I am missing?
Thanks!
Nate

I had the case wrong. It should be “InvokeExecute”. Thanks to an old post from Jose!

I know you showed me how to use an EPIBinding here, but is there any way to link to a unbound text field? For example:

public void CreateEcoRevOpsBAQDV()
	{
		ecoRevOpsBAQDV = new BAQDataView("getPartRevOpECO"); //baq name
		oTrans.Add("EcoRevOpsBAQDV",ecoRevOpsBAQDV); 
		string pub1Binding = txtPartNum.Text; //Native form linking field 1
		IPublisher pub1 = oTrans.GetPublisher(pub1Binding);
		if(pub1==null) 
		{ 
			string pubName = Guid.NewGuid().ToString();
			oTrans.PublishColumnChange(pub1Binding, pubName);
			pub1 = oTrans.GetPublisher(pub1Binding);
		} 
		if(pub1 !=null) 
			ecoRevOpsBAQDV.SubscribeToPublisher(pub1.PublishName, "ECORev_PartNum"); //BAQ linking field 1

		string pub2Binding = cmbRevNum.Text; //Native form linking field 2
		IPublisher pub2 = oTrans.GetPublisher(pub2Binding);
		if(pub2==null) 
		{ 
			string pubName = Guid.NewGuid().ToString();
			oTrans.PublishColumnChange(pub2Binding, pubName);
			pub2 = oTrans.GetPublisher(pub2Binding);
		} 
		if(pub2 !=null) 
			ecoRevOpsBAQDV.SubscribeToPublisher(pub2.PublishName, "ECORev_RevisionNum");//BAQ linking field 2
	
	}

I want to link to my unbound text box, txtPartNum, and BAQ combo, cmbRevNum. Is this kind of thing possible? Thanks!
Nate

1 Like

I have added a BAQ DataView to the TimePhase screen.
Unfortunately however the BAQ DataView does not always change when a new Part Number is entered within the screen.
When I launch Time Phase using open with - the data is always correct but if I remain inside the screen and change the PartNumber is doesn’t always refresh the data view.
Is there a way to ‘force’ an update everytime the PartNum is changed?
Roberto

What are you binding to in the code?

string pubBinding = "???.PartNum";

We use the Misc.PartNum on our customizations and it works when you switch part numbers.

I am using:
string pubBinding = “Part.PartNum”;

I have changed to:
string pubBinding = “Misc.PartNum”;

Now seems to be working - the behavior is inconsistent when you use Part.PartNum - it would work only sometimes.

If you look at the properties of that field when you’re in the customization box, it shows that it is bound to Misc.PartNum which is why it works more consistently.

Indeed - very odd.
I didn’t think about checking that field for the binding.
Hopefully now it will work as expected.
Thanks for the assistance - much appreciated.

Apologies for bumping this older thread… but I’m trying to get this to work by adding a UltraGrid to a custom dashboard “tracker view”. Unfortunately, when I attempted to add the code, I only have “public static class”. I receive an error that I cannot declare instance members in a static class.

Can I simply add a public class to the script editor to get it to work?

@dcamlin , are you trying to do this in dashboard maintenance? Or did you deploy it an create a proper customization? You have to create a customization to do this, as the dashboard maintenance thing can only do limited customizations.

Yeah… I just stumbled on another post recommending that as well. My apologies for duplicating errors others have already addressed. I WAS attempting to do this within Dashboard Maint. I will switch over and attempt as a customization.

I’m not sure if should be apologizing for “necroposting”. These code suggestions are still relevant just as much today as they were four years ago when Carson first published the topic. That, and I really do want to ping the contributors since they are the ones most qualified to answer follow up questions.

Anyhoo, I’ve done my solid best to apply this logic – and all the follow-up ideas – to my own situation and am still coming up dry as a well. What I would like to do is to add an epiUltraGrid to Price List Inquiry so I can show the QOH that is currently in each warehouse. Here’s my screen customization code:

// **************************************************
// Custom code for PriceListInquiryForm
// Created: 6/5/2024 1:35:46 PM
// **************************************************

extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_Warehse;
extern alias Erp_Contracts_BO_Customer;
extern alias Erp_Contracts_BO_Currency;

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.BO;
using Ice.BO.DynamicQuery;
using Ice.Lib.Broadcast;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;

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

	private EpiDataView edvOnHandQtyForPartByWhse_BAQDV;
	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **
	BAQDataView onHandQtyForPartByWhse_BAQDV;
	string curPartNum = "";

	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

		SetExtendedProperties();
		// End Wizard Added Custom Method Calls
		// Adds the current version's description to the title bar. Code should be placed in the
		//  InitializeCustomCode method, after the Wizard Added Custom Method calls. Also, be
		// sure to add Ice.Contracts.BO.DynamicQuery.dll using Tools Assembly Reference Manager.
		string[] parts = csm.CustomAssembly.ToString().Split('.');
		string cmz = (parts[Array.FindIndex(parts,x => x.Equals("Customization"))+1]);
		DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
		dqa.BOConnect();
		Ice.BO.QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("CustomizationLookup");
		qeds.ExecutionParameter.Clear();
		qeds.ExecutionParameter.AddExecutionParameterRow("CMZID",cmz,"nvarchar",false,Guid.Empty,"A");
		dqa.ExecuteByID("CustomizationLookup",qeds);
		oTrans.EpiBaseForm.Text = dqa.QueryResults.Tables["Results"].Rows[0]["XXXDEF_Description"].ToString();
		CreateOnHandQtyForPartByWhseBAQDV();
	}

	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
	}

	private void SetExtendedProperties()
	{
		// Begin Wizard Added EpiDataView Initialization
		EpiDataView edvCustomerSearch = ((EpiDataView)(this.oTrans.EpiDataViews["CustomerSearch"]));
		// End Wizard Added EpiDataView Initialization

		// Begin Wizard Added Conditional Block
		if (edvCustomerSearch.dataView.Table.Columns.Contains("Name"))
		{
			// Begin Wizard Added ExtendedProperty Settings: edvCustomerSearch-Name
			edvCustomerSearch.dataView.Table.Columns["Name"].ExtendedProperties["ReadOnly"] = true;
			// End Wizard Added ExtendedProperty Settings: edvCustomerSearch-Name
		}
		// End Wizard Added Conditional Block
	}

	public void CreateOnHandQtyForPartByWhseBAQDV()
	{
		// Code modeled from Carson Ripple's YouTube video "Epicor BAQ DataView"
		onHandQtyForPartByWhse_BAQDV = new BAQDataView("maOnHandQtyForPartByWhse");
		oTrans.Add("OnHandQtyForPartByWhse_BAQDV",onHandQtyForPartByWhse_BAQDV); 
		string pubPartBinding = "PriceLstParts.PartNum"; 
		IPublisher pub = oTrans.GetPublisher(pubPartBinding);
	
		if(pub == null) 
		{ 
			string pubName = Guid.NewGuid().ToString();
			oTrans.PublishColumnChange(pubPartBinding, pubName);
			pub = oTrans.GetPublisher(pubPartBinding);
		}
	 
		if(pub != null)
		{
			onHandQtyForPartByWhse_BAQDV.SubscribeToPublisher(pub.PublishName, "Part_PartNum");
		}
	}
}

and here’s the BAQ:

select 
	[PartWhse].[PartNum] as [PartWhse_PartNum],
	[PartWhse].[WarehouseCode] as [PartWhse_WarehouseCode],
	[Warehse].[Description] as [Warehse_Description],
	[PartWhse].[OnHandQty] as [PartWhse_OnHandQty]
from Erp.Part as Part
inner join Erp.PartWhse as PartWhse on 
	PartWhse.Company = Part.Company
	and PartWhse.PartNum = Part.PartNum
	and ( PartWhse.Company = @CurComp  and PartWhse.OnHandQty > 0  )

inner join Erp.Warehse as Warehse on 
	PartWhse.Company = Warehse.Company
	and PartWhse.WarehouseCode = Warehse.WarehouseCode

The epiUltraGrid specifies “OnHandQtyForPartByWhse_BAQDV” as the Binding. I have also verified that PriceLstParts.PartNum is accurate having looked at the binding for the Price List > Part Details > Parts grid which does in fact populate nicely when a part is entered. Unfortunately, my grid does not populate.

Any ideas what I may have overlooked here?

Normally is best to create your own topic with links back to relevant posts where you gathered your ideas. That being said, have you verified your data from the BAQ in a dashboard with tracker param to test it? Did you properly set the epiBinding to attach the DV to the ultragrid?

Thanks Clint. That makes total sense. We do the exact same thing in our Jira help desk system. I will certainly link my new topic with the old one next time around.

As for my issue, I realized that the line

onHandQtyForPartByWhse_BAQDV.SubscribeToPublisher(pub.PublishName, "Part_PartNum");

needed to be changed to

onHandQtyForPartByWhse_BAQDV.SubscribeToPublisher(pub.PublishName, "PartWhse_PartNum");

to match my BAQ.

Once that was done, the epiUltraGrid worked like a charm. :four_leaf_clover:

Cheers,
Tony G.

2 Likes

Is there a demo on how to do a UBAQ grid on a form like this?