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

Hi,
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 (Grid Property Changed - #6 by skearney) 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…
Thanks.

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.

image

// 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

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

	}

	public void CreateBinChoicesBAQView()
	{
		baqBinChoices = new BAQDataView("603Manu-Bins");
		oTrans.Add("BinChoicesBAQ",baqBinChoices);

		string pubBinding = "ReceiptRcvDtl.POLinePartNum"; 
		IPublisher pub = oTrans.GetPublisher(pubBinding);
		if(pub==null)
		{
			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[] {
				warningReceiptRcvDtl_PONum};
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleReceiptRcvDtlPOCommentNotEqual_Constant_NullValue = new RowRule("ReceiptRcvDtl.POComment", RuleCondition.NotEqual, "Constant: NullValue", ruleActions);
		((EpiDataView)(this.oTrans.EpiDataViews["ReceiptRcvDtl"])).AddRowRule(rrCreateRowRuleReceiptRcvDtlPOCommentNotEqual_Constant_NullValue);
		// **** 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.

Thanks

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…

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: