Passing Variables from MES to BAQ Report Report using LFO

I’ve got the LFO set up correctly on the program and I believe that it is passing along the correct data. I put two message boxes in just to be sure. However, when the report opens nothing is passed into it. I am trying to figure out what code is needed to handle the incoming information from the LFO. I have gone over these forum posts and had no success.

--------------------------------Code for MES Customization--------------------------------------
// **************************************************
// Custom code for MESMenu
// Created: 11/21/2019 9:46:44 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
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 Ice.Core;

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 edvEmpBasic;
// End Wizard Added Module Level Variables **

// Add Custom Module Level Variables Here **

EpiButton btnDash;

public void InitializeCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
	// Begin Wizard Added Variable Initialization
	this.edvEmpBasic = ((EpiDataView)(this.oTrans.EpiDataViews["EmpBasic"]));
	this.edvEmpBasic.EpiViewNotification += new EpiViewNotification(this.edvEmpBasic_EpiViewNotification);
	btnDash = (EpiButton)csm.GetNativeControlReference("fe187107-b719-4a3d-96a8-5f8505ea65ae");

	// End Wizard Added Variable Initialization

	// Begin Wizard Added Custom Method Calls

	// End Wizard Added Custom Method Calls
	this.btnDash.Click += new System.EventHandler(this.btnDash_Click);
}

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

	this.edvEmpBasic.EpiViewNotification -= new EpiViewNotification(this.edvEmpBasic_EpiViewNotification);
	this.edvEmpBasic = null;
	// End Wizard Added Object Disposal

	// Begin Custom Code Disposal

	// End Custom Code Disposal
	this.btnDash.Click -= new System.EventHandler(this.btnDash_Click);
}

private void MESMenu_Load(object sender, EventArgs args)
{
	// Add Event Handler Code
	btnDash.ReadOnly = false;
}


private void btnDash_Click(object sender, System.EventArgs args)

{
			string yourEMP;
			yourEMP = ((Session)oTrans.Session).EmployeeID;
			MessageBox.Show(yourEMP);

            LaunchFormOptions lfo = new LaunchFormOptions();
			
            lfo.ValueIn = yourEMP;
			MessageBox.Show(lfo.ValueIn.ToString());
            ProcessCaller.LaunchForm(oTrans, "UDLBRBAQ", lfo);
			//ProcessCaller.LaunchForm(this.oTrans, "UDLBRBAQ");

}

private void edvEmpBasic_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
	// ** Argument Properties and Uses **
	// view.dataView[args.Row]["FieldName"]
	// args.Row, args.Column, args.Sender, args.NotifyType
	// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
	if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
	{
		if ((args.Row > -1))
		{
			EnableDisableCustomControls(true);
		}
		else
		{
			EnableDisableCustomControls(false);	
		}
	}
}

private void EnableDisableCustomControls(bool iFlag)
{
	btnDash.Enabled = iFlag;
	btnDash.Enabled = iFlag;
}

}

----------------------------------------End Code for MES-----------------------------------------------------------

----------------------------------------My Attempt at handling the info passed on------------------------------
// **************************************************
// Custom code for BAQReportForm
// Created: 11/22/2019 12:17:43 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;

public class Script
{
// ** Wizard Insert Location - Do Not Remove ‘Begin/End Wizard Added Module Level Variables’ Comments! **
// Begin Wizard Added Module Level Variables **
EpiDataView edvReportParam;
// End Wizard Added Module Level Variables **
//DataSet ds = (DataSet)((Dictionary<string,DataSet>)oTrans.GetType().GetField(“filterDataSets”, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).GetValue(oTrans))[“FilterList2”];
EpiDataView edv = oTrans.Factory(“yourEMP”);
// 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

	edvReportParam = oTrans.Factory("ReportParam.field3");
	// 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

	// End Wizard Added Object Disposal

	// Begin Custom Code Disposal

	// End Custom Code Disposal
}

}

-----------------------------------------------End Attempt-----------------------------------------------------

Thanks for the help!

I usually use LFO.ContextValue and not ValueIn. Note if you have multiple input values, you can store them in a List or array.

// Setting values in LFO and calling a form
	private void PrintBillOfLading(int bolNum)
	{
		LaunchFormOptions lfo = new LaunchFormOptions();
		lfo.ContextValue = bolNum;
		lfo.IsModal = true;
		ProcessCaller.LaunchCallbackForm(oTrans, "CustBOLP", lfo); // Not sure why I used LaunchCallbackForm instead of LaunchForm, but either should work.
	}

and

// Retrieving LFO value(s) and assigning to BAQ Report parameters
	private void BAQReportForm_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code
		if (BAQReportForm.LaunchFormOptions != null)
		{
			if (BAQReportForm.LaunchFormOptions.ContextValue != null)
			{
				EpiDataView param = oTrans.Factory("ReportParam");
				param.dataView[param.Row].BeginEdit();
				param.dataView[param.Row]["Field1"] = BAQReportForm.LaunchFormOptions.ContextValue;
				param.dataView[param.Row].EndEdit();
				oTrans.NotifyAll();
			}
		}
	}

You’re the man Tyler! Got it working like a charm. Why do you prefer contextvalue over value in? Just wondering.

Mostly because of the linked post. Using ContextValue for all forms will avoid situations where I’m trying to use ValueIn, but Epicor also wants to use it.

1 Like