Where clause on customisation

HI,

I have added a combo box to search for a warehouse on our eng workbench materials page, I have added the code for the search to work and it works fine.

My issue is I want to amend the ware clause to only return warehouses from the current plant.

I have this in at the moment, but it errors, saying I am missing a reference

string whereClause = string.((Session)oTrans.Session).PlantID);

Any suggestions

Thanks

Can you show us your error message along with the code?

Hi, The code was generated by the wizard, I am just editing the where clause, here is the code and the error.
private void SearchOnWarehseAdapterFillDropDown()
{
// Wizard Generated Search Method
// You will need to call this method from another method in custom code
// For example, [Form]_Load or [Button]_Click

                            bool recSelected;
            string whereClause = string.((Session)oTrans.Session).PlantID);
                            System.Data.DataSet dsWarehseAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "WarehseAdapter", out recSelected, false, whereClause);
                            if (recSelected)
                            {
                                            // Set EpiUltraCombo Properties
                                            this.cmbBackflushWarehouse.ValueMember = "WarehouseCode";
                                            this.cmbBackflushWarehouse.DataSource = dsWarehseAdapter;
                                            this.cmbBackflushWarehouse.DisplayMember = "Description";
                                            string[] fields = new string[] {
                                                                            "Description"};
                                            this.cmbBackflushWarehouse.SetColumnFilter(fields);
                            }
            }

            private void EngWorkBenchEntryForm_Load(object sender, EventArgs args)
            {
                            SearchOnWarehseAdapterFillDropDown();
            }

}

Compiling Custom Code …

----------errors------------

Error: CS1001 - line 60 (559) - Identifier expected
Error: CS1002 - line 60 (559) - ; expected
Error: CS1525 - line 60 (559) - Invalid expression term ‘)’

Can you try
string whereClause = oTrans.Session.PlantID.ToString();

Just the one error now

// Wizard Generated Search Method
                            // You will need to call this method from another method in custom code
                            // For example, [Form]_Load or [Button]_Click

                            bool recSelected;
                          string whereClause = string.((Session)oTrans.Session).PlantID.ToString();
                            System.Data.DataSet dsWarehseAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "WarehseAdapter", out recSelected, false, whereClause);
                            if (recSelected)
                            {
                                            // Set EpiUltraCombo Properties
                                            this.cmbBackflushWarehouse.ValueMember = "WarehouseCode";
                                            this.cmbBackflushWarehouse.DataSource = dsWarehseAdapter;
                                            this.cmbBackflushWarehouse.DisplayMember = "Description";
                                            string[] fields = new string[] {
                                                                            "Description"};
                                            this.cmbBackflushWarehouse.SetColumnFilter(fields);
                            }

Compiling Custom Code …

----------errors------------

Error: CS1001 - line 60 (559) - Identifier expected

** Compile Failed. **

Sorry, edited my response while you were trying that. Please try with the edited one.

   It still doesn't like it

                     bool recSelected;
                            string whereClause = oTrans.Session.PlantID.ToString();
                            System.Data.DataSet dsWarehseAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "WarehseAdapter", out recSelected, false, whereClause);
                            if (recSelected)

Compiling Custom Code …

----------errors------------

Error: CS1061 - line 60 (559) - ‘object’ does not contain a definition for ‘PlantID’ and no extension method ‘PlantID’ accepting a first argument of type ‘object’ could be found (are you missing a using directive or an assembly reference?)

** Compile Failed. **

Just looking at the object explorer for this form.
try
string whereClause = oTrans.CoreSession.PlantID.ToString();

1 Like

brilliant, that has compiled,

thank you very much

Andy

Glad it worked for you!