Work Queue Customization stops working after reopening

So, I’ve created a filter on my work queue using a BAQcombo and a little bit of code. The BAQcombo lists the Resources in the active Resource Group. The code filters the list of jobs down to the selected resource in the combo. Works great… Now I want to filter out jobs who’s OpDtlDescription starts with “AA”.

It appears to work when I first launch the Work Queue from MES, but If I close the Work Queue and reopen it, without closing MES, the Resource filter still works but it will start displaying jobs regardless if the OpDtlDescription starts with “AA” or not. I don’t get it. Here’s my code, you can see that I’ve tried a few different ways, each with the same result. Decided to leave them in just case I need to go back to using them.

// **************************************************
// Custom code for WorkQueueForm
// Created: 1/21/2019 4:37:32 PM
// **************************************************

extern alias Erp_Contracts_BO_EmpBasic;
extern alias Erp_Contracts_BO_ResourceGroup;
extern alias Erp_Contracts_BO_Resource;

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

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

EpiUltraGrid gridcw;
BAQCombo combo;

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

gridcw = (Ice.Lib.Framework.EpiUltraGrid)csm.GetNativeControlReference("b3e2940f-c81e-4838-9d16-90eff26f2e04");
    gridcw.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.True;

combo = (Ice.Lib.Framework.BAQCombo)csm.GetNativeControlReference("63e9bbfc-8e80-43aa-82a6-ad22971c8f3b");

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

this.combo.TextChanged += new System.EventHandler(this.combo_TextChanged);	

		CreateRowRuleCurrentWorkOpDtlDescriptionStartsWith_AA_();;
		// 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.combo.TextChanged -= new System.EventHandler(this.combo_TextChanged);

		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

    private void Filter() 

	{

        Infragistics.Win.UltraWinGrid.FilterCondition fc = new Infragistics.Win.UltraWinGrid.FilterCondition();
        fc.CompareValue = combo.Text;
        fc.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.Equals;
        gridcw.DisplayLayout.Bands[0].ColumnFilters["ResourceID"].FilterConditions.Add(fc);

        //Infragistics.Win.UltraWinGrid.FilterCondition fc2 = new Infragistics.Win.UltraWinGrid.FilterCondition();
        //fc2.CompareValue = "AA-CNC WHEEL CELL";
        //fc2.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.NotEquals;
        //gridcw.DisplayLayout.Bands[0].ColumnFilters["OpDtlDescription"].FilterConditions.Add(fc2);

		//Infragistics.Win.UltraWinGrid.FilterCondition fc3 = new Infragistics.Win.UltraWinGrid.FilterCondition();
        //fc3.CompareValue = "WHEELABRATE";
        //fc3.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.NotEquals;
        //gridcw.DisplayLayout.Bands[0].ColumnFilters["OpDtlDescription"].FilterConditions.Add(fc3);

		//Infragistics.Win.UltraWinGrid.FilterCondition fc4 = new Infragistics.Win.UltraWinGrid.FilterCondition();
        //fc4.CompareValue = "AA-CNC RIG CELL";
        //fc4.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.NotEquals;
        //gridcw.DisplayLayout.Bands[0].ColumnFilters["OpDtlDescription"].FilterConditions.Add(fc4);

        //Infragistics.Win.UltraWinGrid.FilterCondition fc5 = new Infragistics.Win.UltraWinGrid.FilterCondition();
        //fc5.CompareValue = "AA-WHEEL CELL CNC";
        //fc5.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.NotEquals;
        //gridcw.DisplayLayout.Bands[0].ColumnFilters["OpDtlDescription"].FilterConditions.Add(fc5);

		//Infragistics.Win.UltraWinGrid.FilterCondition fc6 = new Infragistics.Win.UltraWinGrid.FilterCondition();
        //fc6.CompareValue = "AA-RIG CELL CNC";
        //fc6.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.NotEquals;
        //gridcw.DisplayLayout.Bands[0].ColumnFilters["OpDtlDescription"].FilterConditions.Add(fc6);

        // set the logical operator of the columns on the band
        //gridcw.DisplayLayout.Bands[0].ColumnFilters.LogicalOperator = Infragistics.Win.UltraWinGrid.FilterLogicalOperator.And;

    }

	private void combo_TextChanged(object sender, System.EventArgs args)
	{

		gridcw.DisplayLayout.Bands[0].ColumnFilters["ResourceID"].FilterConditions.Clear(); //clear any existing filters
    		//if(combo.Text != "")  //don't filter if we have no text
			Filter();
        		//gridcw.DisplayLayout.Bands[0].ColumnFilters["ResourceID"].FilterConditions.Add  (FilterComparisionOperator.Equals, combo.Text);  //add filter from combo value
				//gridew.DisplayLayout.Bands[0].ColumnFilters["ResourceID"].FilterConditions.Add  (FilterComparisionOperator.Equals, combo.Text); 
				//gridav.DisplayLayout.Bands[0].ColumnFilters["ResourceID"].FilterConditions.Add  (FilterComparisionOperator.Equals, combo.Text);			
				//gridcw.DisplayLayout.Bands[0].ColumnFilters["OpDtlDescription"].FilterConditions.Add  (FilterComparisionOperator.NotEquals, "WHEELABRATE");  //add filter for Op Detail Description
				//gridew.DisplayLayout.Bands[0].ColumnFilters["OpDtlDescription"].FilterConditions.Add  (FilterComparisionOperator.NotEquals, "AA-CNC WHEEL CELL"); 
				//gridav.DisplayLayout.Bands[0].ColumnFilters["OpDtlDescription"].FilterConditions.Add  (FilterComparisionOperator.NotEquals, "AA-CNC RIG CELL");
				//gridcw.DisplayLayout.Bands[0].ColumnFilters.LogicalOperator = Infragistics.Win.UltraWinGrid.FilterLogicalOperator.And;

	}

	//private void CreateRowRuleCurrentWorkOpDtlDescriptionStartsWith_AA_()
	//{
		// Description: HIDE_UNSCHEDULED
		// **** begin autogenerated code ****
		//RuleAction invisibleCurrentWork_RowAction = RuleAction.AddRowSettings(this.oTrans, "CurrentWork", true, SettingStyle.Invisible);
		//RuleAction[] ruleActions = new RuleAction[] {
				//invisibleCurrentWork_RowAction};
		// Create RowRule and add to the EpiDataView.
		//RowRule rrCreateRowRuleCurrentWorkOpDtlDescriptionStartsWith_AA_ = new RowRule("CurrentWork.OpDtlDescription", RuleCondition.StartsWith, "AA-", ruleActions);
		//((EpiDataView)(this.oTrans.EpiDataViews["CurrentWork"])).AddRowRule(rrCreateRowRuleCurrentWorkOpDtlDescriptionStartsWith_AA_);
		// **** end autogenerated code ****
	}

//}

Any suggestions or help would be greatly appreciated!!

Thank you!

1 Like

In the mean time, I’m using the built in filters on the columns to do this but I’d ultimately like to be able to set this in code.

Can you take some screen shots or (or a GIF or video) of what you are seeing?

The BAQcombo in the top right, labeled “Resource”, filters the job list by the “Res ID” column. I’m trying to code it so that it will not display jobs that start with “AA” in the “Op Dtl Desc” column either, that way it only display jobs with the correct “Res ID” and the correct “Op Dtl Desc”. In this example, that would be jobs that have “HAND TOOLS” in both of those columns. Only 2 lines in the picture above.

It does it correctly the first time I launch MES and the Work Queue. If I close the Work Queue and relaunch it, without closing MES entirely, I get the results above.

I don’t see in the code where you are setting the Op Desc column to have a filter on it. The only one I see if for Resource ID.

And all of your commented code has the full description. Why not just use a does not start with AA?

Yeah, I tried using does not start with AA, then realized some of the other resource don’t need to be filtered by this. That’s why I had to use not equals and use the whole text value.

Below is what I was using when I noticed the problem.

// **************************************************
// Custom code for WorkQueueForm
// Created: 1/21/2019 4:37:32 PM
// **************************************************

extern alias Erp_Contracts_BO_EmpBasic;
extern alias Erp_Contracts_BO_ResourceGroup;
extern alias Erp_Contracts_BO_Resource;

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
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 Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using Infragistics.Shared;

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

EpiUltraGrid gridcw;
EpiTextBox txtJobNum;
BAQCombo combo;

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

gridcw = (Ice.Lib.Framework.EpiUltraGrid)csm.GetNativeControlReference("b3e2940f-c81e-4838-9d16-90eff26f2e04");
    gridcw.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.True;

combo = (Ice.Lib.Framework.BAQCombo)csm.GetNativeControlReference("63e9bbfc-8e80-43aa-82a6-ad22971c8f3b");

txtJobNum = (Ice.Lib.Framework.EpiTextBox)csm.GetNativeControlReference("161630a6-3c50-42e1-afd7-15d9d36c8167");

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

this.combo.TextChanged += new System.EventHandler(this.combo_TextChanged);

this.txtJobNum.TextChanged += new System.EventHandler(this.txtJobNum_TextChanged);

		// 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.combo.TextChanged -= new System.EventHandler(this.combo_TextChanged);

this.txtJobNum.TextChanged -= new System.EventHandler(this.txtJobNum_TextChanged);

		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

    private void Filter() 

	{

        Infragistics.Win.UltraWinGrid.FilterCondition fc = new Infragistics.Win.UltraWinGrid.FilterCondition();
        fc.CompareValue = combo.Text;
        fc.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.Equals;
        gridcw.DisplayLayout.Bands[0].ColumnFilters["ResourceID"].FilterConditions.Add(fc);

        Infragistics.Win.UltraWinGrid.FilterCondition fc2 = new Infragistics.Win.UltraWinGrid.FilterCondition();
        fc2.CompareValue = "AA-CNC WHEEL CELL";
        fc2.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.NotEquals;
        gridcw.DisplayLayout.Bands[0].ColumnFilters["OpDtlDescription"].FilterConditions.Add(fc2);

		Infragistics.Win.UltraWinGrid.FilterCondition fc3 = new Infragistics.Win.UltraWinGrid.FilterCondition();
        fc3.CompareValue = "WHEELABRATE";
        fc3.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.NotEquals;
        gridcw.DisplayLayout.Bands[0].ColumnFilters["OpDtlDescription"].FilterConditions.Add(fc3);

		Infragistics.Win.UltraWinGrid.FilterCondition fc4 = new Infragistics.Win.UltraWinGrid.FilterCondition();
        fc4.CompareValue = "AA-CNC RIG CELL";
        fc4.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.NotEquals;
        gridcw.DisplayLayout.Bands[0].ColumnFilters["OpDtlDescription"].FilterConditions.Add(fc4);

        Infragistics.Win.UltraWinGrid.FilterCondition fc5 = new Infragistics.Win.UltraWinGrid.FilterCondition();
        fc5.CompareValue = "AA-WHEEL CELL CNC";
        fc5.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.NotEquals;
        gridcw.DisplayLayout.Bands[0].ColumnFilters["OpDtlDescription"].FilterConditions.Add(fc5);

		Infragistics.Win.UltraWinGrid.FilterCondition fc6 = new Infragistics.Win.UltraWinGrid.FilterCondition();
        fc6.CompareValue = "AA-RIG CELL CNC";
        fc6.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.NotEquals;
        gridcw.DisplayLayout.Bands[0].ColumnFilters["OpDtlDescription"].FilterConditions.Add(fc6);

        // set the logical operator of the columns on the band
        gridcw.DisplayLayout.Bands[0].ColumnFilters.LogicalOperator = Infragistics.Win.UltraWinGrid.FilterLogicalOperator.And;

    }

	private void Filter2() 

	{
        Infragistics.Win.UltraWinGrid.FilterCondition fc = new Infragistics.Win.UltraWinGrid.FilterCondition();
        fc.CompareValue = txtJobNum.Text;
        fc.ComparisionOperator = Infragistics.Win.UltraWinGrid.FilterComparisionOperator.StartsWith;
        gridcw.DisplayLayout.Bands[0].ColumnFilters["JobNum"].FilterConditions.Add(fc);
	}

	private void combo_TextChanged(object sender, System.EventArgs args)
	{
		gridcw.DisplayLayout.Bands[0].ColumnFilters["JobNum"].FilterConditions.Clear();
		gridcw.DisplayLayout.Bands[0].ColumnFilters["ResourceID"].FilterConditions.Clear(); //clear any existing filters
    		if(combo.Text != "")  //don't filter if we have no text
			Filter();

	}

	private void txtJobNum_TextChanged(object sender, System.EventArgs args)
	{

		gridcw.DisplayLayout.Bands[0].ColumnFilters["ResourceID"].FilterConditions.Clear(); //clear any existing filters
		gridcw.DisplayLayout.Bands[0].ColumnFilters["JobNum"].FilterConditions.Clear();
    		if(txtJobNum.Text != "")  //don't filter if we have no text
			Filter2();
	}
}

Note, I’ve added another filter on the job number text box since then. That works, but still same results. I get the AA-CNC* stuff on my Op Detail column.

I have gotten around this by using the built in filter on the column, pictured below.

image

Saved the layout as a personilaztion and it works beautifully. I just don’t understand why my code didn’t function the same way.

Well, that code should be doing exactly what you are doing manually. So if it’s working, you should be able to see the filters in the same box. I can see in your screen shot that the filters for the other stuff is active (a different blue). Do the filters populate like that when you open it the first time?

The coded filters don’t appear in the Custom Filter box. Although, I guess I could preview the entire code and see how it does it from the Custom Filters box.

No, the filters don’t get triggered until a user either selects a resource in the drop down BAQcombo or they start typing a job into the Job text box.

I’m not going to worry about it too much. It works now. Should never fix something that works lol.