Hello,
I am currently working on configuring a report to display when the beginning of a part matches specific criteria. I have previously implemented a similar functionality using a plant filter, which identifies the plant based on the user’s location. However, when attempting to apply the same method for this new criteria, I encounter four errors upon execution, despite the code compiling successfully.
Below is the code used for the plant customization:
// **************************************************
// Custom code for BAQReportForm
// Created: 20/01/2021 16:40:02
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.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;
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 edvReportParam;
string plant;
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
this.edvReportParam = ((EpiDataView)(this.oTrans.EpiDataViews["ReportParam"]));
this.edvReportParam.EpiViewNotification += new EpiViewNotification(this.edvReportParam_EpiViewNotification);
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
// 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.edvReportParam.EpiViewNotification -= new EpiViewNotification(this.edvReportParam_EpiViewNotification);
this.edvReportParam = null;
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void edvReportParam_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
if ((args.Row > -1))
{
if(plant == "HAS")
{
view.dataView[0]["ReportStyleNum"] = 1002; // Haslingden
}
else
{
view.dataView[0]["ReportStyleNum"] = 1; // Dunstable and Hull
}
}
}
private void BAQReportForm_Load(object sender, EventArgs args)
{
if (BAQReportForm.LaunchFormOptions != null)
{
string jobNum = BAQReportForm.LaunchFormOptions.ContextValue.ToString();
edvReportParam.dataView[edvReportParam.Row]["field1"] = jobNum;
DataTable dtPlant = new DataTable();
DynamicQueryAdapter baqAdapter = new DynamicQueryAdapter(oTrans);
baqAdapter.BOConnect();
QueryExecutionDataSet parameters = new QueryExecutionDataSet();
DataRow paramRow;
paramRow = parameters.ExecutionParameter.NewRow();
paramRow["ParameterID"] = "paramJobNum";
paramRow["ParameterValue"] = jobNum;
paramRow["ValueType"] = "string";
paramRow["RowMod"] = "A";
paramRow["SysRowID"] = new Guid("00000000-0000-0000-0000-000000000000");
parameters.ExecutionParameter.Rows.Add(paramRow);
baqAdapter.ExecuteByID("BAQ_Plant_From_Job", parameters);
dtPlant = baqAdapter.QueryResults.Tables["Results"];
plant = dtPlant.Rows[0]["JobHead_Plant"].ToString();
}
}
}
Here is the code for the criteria customization:
// **************************************************
// Custom code for PackingSlipPrintForm
// Created: 15/08/2024 09:43:47
// **************************************************
extern alias Erp_Contracts_BO_CustShip;
extern alias Erp_Contracts_BO_ReportQty;
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.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;
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 edvReportParam;
string partNum;
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
this.edvReportParam = ((EpiDataView)(this.oTrans.EpiDataViews["ReportParam"]));
this.edvReportParam.EpiViewNotification += new EpiViewNotification(this.edvReportParam_EpiViewNotification);
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
// 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.edvReportParam.EpiViewNotification -= new EpiViewNotification(this.edvReportParam_EpiViewNotification);
this.edvReportParam = null;
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void edvReportParam_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
if ((args.Row > -1))
{
if(partNum.StartsWith("PRE003"))
{
MessageBox.Show(partNum);
view.dataView[0]["ReportStyleNum"] = 1007;
}
}
}
private void PackingSlipPrintForm_Load(object sender, EventArgs args)
{
MessageBox.Show("1,2,3"); // error handling
if (PackingSlipPrintForm.LaunchFormOptions != null)
{
MessageBox.Show("3,2,1"); // error handling
string jobNum = PackingSlipPrintForm.LaunchFormOptions.ContextValue.ToString();
edvReportParam.dataView[edvReportParam.Row]["field1"] = jobNum;
DataTable dtPartNum = new DataTable(); // create a new datatable based in part number
DynamicQueryAdapter baqAdapter = new DynamicQueryAdapter(oTrans);
baqAdapter.BOConnect();
QueryExecutionDataSet parameters = new QueryExecutionDataSet();
DataRow paramRow;
paramRow = parameters.ExecutionParameter.NewRow();
paramRow["ParameterID"] = "paramPartNum";
paramRow["ParameterValue"] = jobNum;
paramRow["ValueType"] = "string";
paramRow["RowMod"] = "A";
paramRow["SysRowID"] = new Guid("00000000-0000-0000-0000-000000000000");
parameters.ExecutionParameter.Rows.Add(paramRow);
baqAdapter.ExecuteByID("BAQ_PFP", parameters);
dtPartNum = baqAdapter.QueryResults.Tables["Results"];
partNum = dtPartNum.Rows[0]["ShipDtl_PartNum"].ToString();
MessageBox.Show(dtPartNum.Rows[0]["ShipDtl_PartNum"].ToString());
}
}
}
I would greatly appreciate it if anyone familiar with this issue could provide a solution or offer assistance.
Thank you in advance for your help.