Filtering new Grid on new sheet from existing sheet field value when loaded

I need to provide the value (after the data is first loaded to the UI) from ReceiptRcvDtl.POLinePartNum that is in an existing customization, as a parameter to an EpiUtlraGrid that uses a BAQ (w/o the PartNum parameter to avoid the manual need to enter PartNum via parameter popup.
I currently have the grid set to an EpiBinding that references publish/subscribe C# code) like @josecgomez had in his video found within ( and I also added a button with his code to refresh it. It will load data into the grid when I click it if I have done a refresh/save (I think). However, it is ignoring the magic filtering I was hoping for and I temporarily put a TOP 10 in the BAQ while I’m getting this worked out.
I’ve also tried a DashBoard on another new sheet (all sheets are at the ReceiptDetailDockPanel1 level) with a DashBoardBrowse filter and that being subscribed to the Data View. That seemed like it was working with the filtering, but then it starting returning all the data and I could not get it working again.
I can include more details if needed…

I’ve probably missed the easy way of doing this, but learned a bunch along the way from previous expert contributors…

I’m not sure I follow… if you are using PublishSubscribe it should just work nativelly as long as you are Publishing / Subscribing to the field correctly.
Can you show us (what you are trying to do)
And share your code.

Sure and thank you…
I need the field labeled Our Part: (for which I am showing the tech info) to be the filter for the grid on the Bin Choices sheet.


// Custom code for ReceiptEntryForm
// Created: 11/29/2016 2:49:20 PM
// **************************************************

extern alias Erp_Contracts_BO_Receipt;
extern alias Erp_Contracts_BO_ICReceiptSearch;
extern alias Erp_Contracts_BO_SupplierXRef;
extern alias Erp_Contracts_BO_Currency;
extern alias Erp_Contracts_BO_Company;
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_Vendor;
extern alias Erp_Contracts_BO_VendorPPSearch;
extern alias Erp_Contracts_BO_JobEntry;
extern alias Erp_Contracts_BO_JobAsmSearch;

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 baqBinChoices;

	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

		this.epiButtonC1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.epiButtonC1_MouseDown);
		// End Wizard Added Custom Method Calls


	public void CreateBinChoicesBAQView()
		baqBinChoices = new BAQDataView("603Manu-Bins");

		string pubBinding = "ReceiptRcvDtl.POLinePartNum"; 
		IPublisher pub = oTrans.GetPublisher(pubBinding);
			oTrans.PublishColumnChange(pubBinding, "MyCustomPublish");
			pub = oTrans.GetPublisher(pubBinding);
//MessageBox.Show ("Dave - Was Not Published.");

		if(pub !=null)
			baqBinChoices.SubscribeToPublisher(pub.PublishName, "PartBin_PartNumber");
//MessageBox.Show ("Dave - Subscribed.");

	public void DestroyCustomCode()
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		this.epiButtonC1.MouseDown -= new System.Windows.Forms.MouseEventHandler(this.epiButtonC1_MouseDown);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal

	private void CreateRowRuleReceiptRcvDtlPOCommentNotEqual_Constant_NullValue()
		// Description: CommentsCheck
		// **** begin autogenerated code ****
		RuleAction warningReceiptRcvDtl_PONum = RuleAction.AddControlSettings(this.oTrans, "ReceiptRcvDtl.PONum", SettingStyle.Warning);
		RuleAction[] ruleActions = new RuleAction[] {
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleReceiptRcvDtlPOCommentNotEqual_Constant_NullValue = new RowRule("ReceiptRcvDtl.POComment", RuleCondition.NotEqual, "Constant: NullValue", ruleActions);
		// **** end autogenerated code ****

	private void epiButtonC1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs args)
		// ** Place Event Handling Code Here **
	MethodInfo mi = baqBinChoices.GetType().GetMethod("invokeExecute", BindingFlags.Instance | BindingFlags.NonPublic);
	mi.Invoke(baqBinChoices, new object[]{ true });

And you only want it to execute on button click?

No I wanted it to execute automatically. I added the button to aid me in debugging.


IAre you sure that’s the name of the field / data view yo are subscribing to? Are yo sure it is not just RcvDtl?

Well, I did find a problem where it should have been this
baqBinChoices.SubscribeToPublisher(pub.PublishName, “PartBin_PartNum”);

and not “PartBin_PartNumber”

However, it’s still not working and I did try
string pubBinding = “RcvDtl.POLinePartNum”;

As a test, the only time I have got it to autopopulate (w/o filtering) is with this…
string pubBinding = “Part.PartNum”;

BTW, When trying to get the DashBoard way working…How to view what I set DashBoard DataView/Field to with the wizard after creation of a new CustomSheet? If I go back in and edit it the previous selections don’t show.

What is your field bound to, can you send me a screen shot of the binding proprety for that field (the POLinePart)

here it is…

Via SQL Profiler Trace I’m finding its not working with the filter that’s been tacked onto the CTE. Perhaps it doesn’t like using the alias for the field name. I’m trying some other approaches right now…

declare @p3 Ice.QueryParamTableType
insert into @p3 values(N'603Manu')
insert into @p3 values(N'RFLogic')

exec sp_executesql N'
declare @AvailCompLst table(Company nchar(8) primary key);
insert into @AvailCompLst values(N'''');
insert into @AvailCompLst(Company) select ParamValue from @_compList; 

 with [SubQuery1]  as 
(select  TOP (10)   [PartBin].[BinNum] [PartBin_BinNum],case  
    when [PlantWhse].[PrimBin] <> '''' then ''Master''
    else ''Standard''
end [Calculated_BinLocation],[PartBin].[OnhandQty] [PartBin_OnhandQty],[PartBin].[PartNum] [PartBin_PartNum]
from ( [Erp].[PartBin] inner join @AvailCompLst [AvailCLst_PartBin] on [Erp].[PartBin].[Company] is null  Or [Erp].[PartBin].[Company] = [AvailCLst_PartBin].[Company])
inner join [Erp].[PlantWhse] on [Erp].[PartBin].[PartNum] = [Erp].[PlantWhse].[PartNum] And [Erp].[PartBin].[Company] = [Erp].[PlantWhse].[Company]
where [PartBin].[Company] = N''603Manu'' 
select *
from [SubQuery1]  [SubQuery1]
where (PartBin_PartNum = N''UL3289/10-0-CFM-Anixter'') AND (PartBin_PartNum = N''UL3289/10-0-CFM-Anixter'')

',N'@_compList [Ice].[QueryParamTableType] READONLY,@CurrentUserID nvarchar(max) ',@_compList=@p3,@CurrentUserID=N'dsayward' ```

I got it. It’s working now. That TOP 10 I had in there temporarily was causing it not to work.

1 Like

Right since its a CTE it does TOP 10 first then adds the filter :wink: