EpiUltraGrid BAQDataView Upgrading from 10.2.400 to 2021.2.18

Let me start with, “I’m not really a programmer”.

I have BPMForm customization that I developed a long while back (with a bit of help from @josecgomez & @Banderson) that embeds BAQ data in an epiUltraGrid. This is working in our Production install of 10.2.400. However, during the upgrade process to 2021.2, all the custom codes got removed.

Looks like Epicor moved from private voids to private static voids; which I’m guessing is cause of the issue. I’ve managed to get some of it working (well not error in Test Code) but I’m still stuck with these 4 errors

 Error: CS0120 - line 95 (419) - An object reference is required for the non-static field, method, or property 'Script.baqViewMtlList'
 Error: CS0120 - line 96 (420) - An object reference is required for the non-static field, method, or property 'Script.baqViewMtlList'
 Error: CS0120 - line 120 (444) - An object reference is required for the non-static field, method, or property 'Script.baqViewMtlList'
 Error: CS0120 - line 121 (445) - An object reference is required for the non-static field, method, or property 'Script.baqViewMtlList'
Original Code
// **************************************************
// Custom code for IP_MtlWarning
// Created: 6/21/2019 12:03:16 PM
// **************************************************
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.Broadcast;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using System.Reflection;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;

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 baqViewMtlList;
	EpiUltraGrid eugMtlGrid;

	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.btnLaunchMassIssue.Click += new System.EventHandler(this.btnLaunchMassIssue_Click);
		this.btnIssueMtl.Click += new System.EventHandler(this.btnIssueMtl_Click);
		// End Wizard Added Custom Method Calls
		CreateMtlListBAQView();
	}

public void CreateMtlListBAQView()
	{
	baqViewMtlList = new BAQDataView("OutstandingJobOpMtls");
	oTrans.Add("OutstandingJobOpMtls_BAQ",baqViewMtlList);

    EpiDataView edvBPMdata = (EpiDataView)(oTrans.EpiDataViews["BPMData"]);

    string sJobNum = Convert.ToString(edvBPMdata.dataView[edvBPMdata.Row]["Character01"]);
    int iAsmSeq = Convert.ToInt32(edvBPMdata.dataView[edvBPMdata.Row]["Number01"]);
	
	txtJobNum.Value = sJobNum;
	txtAsmSeq.Value = iAsmSeq;

	string char01Binding = "BPMData.Character01";
	string num01Binding = "BPMData.Number01";
	string num02Binding = "BPMData.Number02";
	IPublisher jobPub = oTrans.GetPublisher(char01Binding);
	IPublisher asmPub = oTrans.GetPublisher(num01Binding);
	if(jobPub==null)
	{
		oTrans.PublishColumnChange(char01Binding, "JobNum");
		jobPub = oTrans.GetPublisher(char01Binding);
		oTrans.PublishColumnChange(num01Binding, "AsmSeq");
		asmPub = oTrans.GetPublisher(num01Binding);
	}
	if(jobPub !=null)
	{
		baqViewMtlList.SubscribeToPublisher(jobPub.PublishName, "JobMtl_JobNum");
		baqViewMtlList.SubscribeToPublisher(asmPub.PublishName, "JobMtl_AssemblySeq");
	}
	jobPub.PublishInitialValue(sJobNum,true);
	var edv = (EpiDataView)(oTrans.EpiDataViews["CallContextBpmData"]);  
	edv.dataView[edv.Row]["Character01"] = sJobNum;
}

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

		this.btnLaunchMassIssue.Click -= new System.EventHandler(this.btnLaunchMassIssue_Click);
		this.btnIssueMtl.Click -= new System.EventHandler(this.btnIssueMtl_Click);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void btnLaunchMassIssue_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		LaunchFormOptions lfo = new LaunchFormOptions();
		lfo.ValueIn = txtJobNum.Value;
		ProcessCaller.LaunchForm(this.oTrans, "IMGO3020",lfo);
	}

	private void IP_MtlWarning_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code
	IP_MtlWarning.StartPosition = FormStartPosition.CenterScreen;
	System.Drawing.Rectangle wa = Screen.PrimaryScreen.WorkingArea;
	IP_MtlWarning.Location = new System.Drawing.Point((wa.Right - IP_MtlWarning.Width) / 2, (wa.Bottom - IP_MtlWarning.Height) / 2);
	}

	private void btnIssueMtl_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		LaunchFormOptions lfo = new LaunchFormOptions();
		lfo.ValueIn = txtJobNum.Value;
		ProcessCaller.LaunchForm(this.oTrans, "IMGO3005", lfo);
	}
}


New Code
// **************************************************
// Custom code for IP_MtlWarning
// Created: 6/3/2022 4:01:06 PM
// **************************************************
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.Broadcast;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using System.Reflection;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;

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 baqViewMtlList;
	EpiUltraGrid eugMtlGrid;

	public static 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

		Script.btnIssueMtl.Click += new System.EventHandler(Script.btnIssueMtl_Click);
		Script.btnLaunchMassIssue.Click += new System.EventHandler(Script.btnLaunchMassIssue_Click);
		// End Wizard Added Custom Method Calls
		CreateMtlListBAQView();
	}

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

		Script.btnIssueMtl.Click -= new System.EventHandler(Script.btnIssueMtl_Click);
		Script.btnLaunchMassIssue.Click -= new System.EventHandler(Script.btnLaunchMassIssue_Click);

		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private static void IP_MtlWarning_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code
	IP_MtlWarning.StartPosition = FormStartPosition.CenterScreen;
	System.Drawing.Rectangle wa = Screen.PrimaryScreen.WorkingArea;
	IP_MtlWarning.Location = new System.Drawing.Point((wa.Right - IP_MtlWarning.Width) / 2, (wa.Bottom - IP_MtlWarning.Height) / 2);
	}

	private static void btnIssueMtl_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		// ** Place Event Handling Code Here **
		LaunchFormOptions lfo = new LaunchFormOptions();
		lfo.ValueIn = txtJobNum.Value;
		ProcessCaller.LaunchForm(Script.oTrans, "IMGO3005", lfo);

	}

	private static void btnLaunchMassIssue_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		// ** Place Event Handling Code Here **
		LaunchFormOptions lfo = new LaunchFormOptions();
		lfo.ValueIn = txtJobNum.Value;
		ProcessCaller.LaunchForm(Script.oTrans, "IMGO3020",lfo);

	}

public static void CreateMtlListBAQView()
	{
	baqViewMtlList = new BAQDataView("OutstandingJobOpMtls");
	oTrans.Add("OutstandingJobOpMtls_BAQ",baqViewMtlList);

    EpiDataView edvBPMdata = (EpiDataView)(oTrans.EpiDataViews["BPMData"]);

    string sJobNum = Convert.ToString(edvBPMdata.dataView[edvBPMdata.Row]["Character01"]);
    int iAsmSeq = Convert.ToInt32(edvBPMdata.dataView[edvBPMdata.Row]["Number01"]);
	
	txtJobNum.Value = sJobNum;
	txtAsmSeq.Value = iAsmSeq;

	string char01Binding = "BPMData.Character01";
	string num01Binding = "BPMData.Number01";
	string num02Binding = "BPMData.Number02";
	IPublisher jobPub = oTrans.GetPublisher(char01Binding);
	IPublisher asmPub = oTrans.GetPublisher(num01Binding);
	if(jobPub==null)
	{
		oTrans.PublishColumnChange(char01Binding, "JobNum");
		jobPub = oTrans.GetPublisher(char01Binding);
		oTrans.PublishColumnChange(num01Binding, "AsmSeq");
		asmPub = oTrans.GetPublisher(num01Binding);
	}
	if(jobPub !=null)
	{
		baqViewMtlList.SubscribeToPublisher(jobPub.PublishName, "JobMtl_JobNum");
		baqViewMtlList.SubscribeToPublisher(asmPub.PublishName, "JobMtl_AssemblySeq");
	}
	jobPub.PublishInitialValue(sJobNum,true);
	var edv = (EpiDataView)(oTrans.EpiDataViews["CallContextBpmData"]);  
	edv.dataView[edv.Row]["Character01"] = sJobNum;
}

}

Any help, guidance, sample code, etc… would be gratefully appreciated.

Thank you,

oh look, it’s 5 pm on a Friday, time for a beer!

Okay, after a night of sleep I tackled this again. I believe I’ve corrected the syntax and it seems to be working correctly now.

"Corrected Code
// **************************************************
// Custom code for IP_MtlWarning
// Created: 6/4/2022 1:00:11 PM
// **************************************************
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;

using Ice.Lib.Broadcast;
using System.Reflection;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;

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


	public static 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

		Script.btnLaunchIssueMtl.Click += new System.EventHandler(Script.btnLaunchIssueMtl_Click);
		Script.btnLaunchMassIssue.Click += new System.EventHandler(Script.btnLaunchMassIssue_Click);
		// End Wizard Added Custom Method Calls
		CreateMtlListBAQView();
	}

public static void CreateMtlListBAQView()
	{
	BAQDataView baqViewMtlList;
	EpiUltraGrid eugMtlGrid;	
		
	baqViewMtlList = new BAQDataView("OutstandingJobOpMtls");
	oTrans.Add("OutstandingJobOpMtls_BAQ",baqViewMtlList);

    EpiDataView edvBPMdata = (EpiDataView)(oTrans.EpiDataViews["BPMData"]);

    string sJobNum = Convert.ToString(edvBPMdata.dataView[edvBPMdata.Row]["Character01"]);
    int iAsmSeq = Convert.ToInt32(edvBPMdata.dataView[edvBPMdata.Row]["Number01"]);
	
	txtJobNum.Value = sJobNum;
	txtAsmSeq.Value = iAsmSeq;

	string char01Binding = "BPMData.Character01";
	string num01Binding = "BPMData.Number01";
	string num02Binding = "BPMData.Number02";
	IPublisher jobPub = oTrans.GetPublisher(char01Binding);
	IPublisher asmPub = oTrans.GetPublisher(num01Binding);
	if(jobPub==null)
	{
		oTrans.PublishColumnChange(char01Binding, "JobNum");
		jobPub = oTrans.GetPublisher(char01Binding);
		oTrans.PublishColumnChange(num01Binding, "AsmSeq");
		asmPub = oTrans.GetPublisher(num01Binding);
	}
	if(jobPub !=null)
	{
		baqViewMtlList.SubscribeToPublisher(jobPub.PublishName, "JobMtl_JobNum");
		baqViewMtlList.SubscribeToPublisher(asmPub.PublishName, "JobMtl_AssemblySeq");
	}
	jobPub.PublishInitialValue(sJobNum,true);
	var edv = (EpiDataView)(oTrans.EpiDataViews["CallContextBpmData"]);  
	edv.dataView[edv.Row]["Character01"] = sJobNum;
	}


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

		Script.btnLaunchIssueMtl.Click -= new System.EventHandler(Script.btnLaunchIssueMtl_Click);
		Script.btnLaunchMassIssue.Click -= new System.EventHandler(Script.btnLaunchMassIssue_Click);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private static void btnLaunchIssueMtl_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
			LaunchFormOptions lfo = new LaunchFormOptions();
			lfo.ValueIn = txtJobNum.Value;
			ProcessCaller.LaunchForm(Script.oTrans, "IMGO3005", lfo);
	}

	private static void btnLaunchMassIssue_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
			LaunchFormOptions lfo = new LaunchFormOptions();
			lfo.ValueIn = txtJobNum.Value;
			ProcessCaller.LaunchForm(Script.oTrans, "IMGO3020",lfo);
	}

	private static void IP_MtlWarning_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code
		IP_MtlWarning.StartPosition = FormStartPosition.CenterScreen;
		System.Drawing.Rectangle wa = Screen.PrimaryScreen.WorkingArea;
		IP_MtlWarning.Location = new System.Drawing.Point((wa.Right - IP_MtlWarning.Width) / 2, (wa.Bottom - IP_MtlWarning.Height) / 2);
	}
}

1 Like