LaunchFormOptions Basic Steps

I am attempting to put a button on the DMR processing screen that pulls up our DMR Form with the DMR number populated from the DMR processing screen. So far I have been able to get the button to open the form, but not pass any info.

Code that works to open BAQ Report form:

ProcessCaller.LaunchForm (oTrans, “UDDMR”);

What I think I need to have to pass information:

LaunchFormOptions lfo = new LaunchFormOptions ();
lfo.IsModal = true;
lfo.ValueIn = ?????????;
ProcessCaller.LaunchForm (oTrans, "UDDMR", lfo);

What do I put in ??? I want the DMR number, I have tried DMRHead.DMRNum (what the field is tied to), I have also tried nedDMRNum (the epiview name?).

I have read a ton of posts but can’t seem to figure out how to reference the field I want.

My next question is about the receiving form. I have to customize it to receive the ValueIn? Do I do this on the screen that pops up for me to print the form from (where I enter the DMR number and choose the report format)?

LFO Basics

In ValueIn you can pass in whatever you like, for example.

Form 1 Button Code:

LaunchFormOptions lfo = new LaunchFormOptions();
lfo.IsModal = true; // true will basically not allow the user to do anything on Form1 until Form2 is closed.
lfo.ValueIn = "Hey Mark Wonsil, Got Anymore Dad Jokes?";
ProcessCaller.LaunchForm(oTrans, "UDDMR", lfo);

I mean anything…

lfo.ValueIn = this.oTrans; // lets just passed all of oTrans - not recommended but yeah you could
lfo.ValueIn = 123;
lfo.ValueIn = new List<int>() { 2, 3, 7 };

Then on the Form you are calling, you can capture the lfo object and read the value, then you do with it whatever you wish on the other side.

Form 2 Example (The Form you are Launching):
I did mine on the _Shown Event because I wanted to seperate my _Load code and dedicate an event of its own.

private void UD100Form_Shown(object sender, EventArgs e)
	// Check for Called
	if (UD100Form.LaunchFormOptions != null && UD100Form.LaunchFormOptions.Sender != null && UD100Form.LaunchFormOptions.ValueIn != null)

		string lfoValue = UD100Form.LaunchFormOptions.ValueIn.ToString();
		string lfoSenderName = UD100Form.LaunchFormOptions.Sender.ToString();

		switch (lfoSenderName)
			case "Erp.UI.Rpt.PackingSlipPrint.Transaction":
				DataSet dsShipDtl = ShipDtlSearchAdapter(lfoValue);

				foreach (DataRow ShipDtlRow in dsShipDtl.Tables[0].Rows)
					jobNum = ShipDtlRow["JobNum"].ToString();


			case "Erp.UI.App.JobEntry.Transaction":
				jobNum = lfoValue;

To Simplify all you really need on the other side to get started it:

	if (UD100Form.LaunchFormOptions != null && UD100Form.LaunchFormOptions.Sender != null && UD100Form.LaunchFormOptions.ValueIn != null)
		string lfoValue = UD100Form.LaunchFormOptions.ValueIn.ToString();
       EpiMessageBox.Show("The Value Passed in is " + lfoValueIn, "Hi", MessageBoxButtons.OK, MessageBoxIcon.Error);

Extra Credit 1 - Communicate Closed Event

You can also communicate between the 2 forms and even detect the closing of the Form Called.

Form 1:

private void btnTest_Click(object sender, System.EventArgs args)
	LaunchFormOptions lfo 	= new LaunchFormOptions();
	lfo.ValueIn				= this.oTrans._packNum;
	//lfo.ContextValue		= this.CreateParamsList(whereClauseUD100A);
	lfo.IsModal				= true;
	lfo.SuppressFormSearch 	= true;
	lfo.LaunchedFormClosed += new EventHandler(lfo_LaunchedFormClosed);
	//lfo.CallBackMethod = CallBackHandlerBAQReport;
	ProcessCaller.LaunchForm(oTrans, "UEVQRT01", lfo);

void lfo_LaunchedFormClosed(object sender, EventArgs e)
	if (((EpiBaseForm)sender).DialogResult == System.Windows.Forms.DialogResult.OK)
		// Do MAGIC Here the sender or e object will have the called form data and LFO Object Result, it literally will send over the entire Object, oTrans info etc... 

Form 2:

UD100Form.DialogResult = DialogResult.OK;
UD100Form.LaunchFormOptions.Result = "HELLO WORLD";

I actually use this when I have a BAQ Form and I want to “Auto-Print” I Launch it, hidden or even visible and then return result and close it.

Extra Credit 2 - Call Back Methods

You can also register a CallBack Method, so Form2 can actually call a Method on Form1. This is one trick I learned from @josecgomez

lfo.CallBackMethod = CallBackHandlerBAQReport;

Form 1:

* Helper which listens to Communication from the BAQ Report
* Invoke from the BAQ Report for example to Refresh UI
* After Printing has happened so the Shape shows up
void CallBackHandlerBAQReport(object sender, object CallBackArgs)
	// Verify CallBack args exist
	if (CallBackArgs == null) {

	// We are passing back a string
	switch (CallBackArgs.ToString())
		case "Refresh":

Form 2: (One being Launched):

if (BAQReportForm.LaunchFormOptions != null)
	if (BAQReportForm.LaunchFormOptions.CallBackMethod != null) {
		BAQReportForm.LaunchFormOptions.CallBackMethod(oTrans, "Refresh");

Basically you can pass back anything as well

BAQReportForm.LaunchFormOptions.CallBackMethod(oTrans, "ANYTHING_I_WISH_HERE");

My Use Case for this is when I Update my Form1 Data using its Adapter on Form2 and then I send a refresh to the background form and it updates. But you can actually do that with the previous discussed method Extra Credit 1 - Communicate Closed Event as well.

The same methods are used for example when you Print a Packing Slip and then the Customer Shipment Form updates with the green shape “Printed” or shows a Message Box…


Great post @hasokeric, @josecgomez Any chance we can have this one put in Experts Corner?

1 Like

Wow! That is a wonderful explanation. Unfortunately it goes right over my head. I still don’t understand how to reference the field I’m looking at (DMR number) in the code. All the example have words in quotes. Do I just put “DMRnumber” right there and it will pick the one I’m looking at?

Then on the Form you are calling, you can capture the lfo object and read the value, then you do with it whatever you wish on the other side.

Do I do this by choosing Customize on the screen that pops up to print my report?

Completely new at this :slight_smile:

I think you are asking how to get the DMRNum value?

First declare a variable to reference the header.

private EpiDataView _edvDMRHead;

then initialize it in the InitializeCustomCode() procedure;

Or you could string it all together in a long statement, but I like to split stuff out :slight_smile:

this.edvDMRHead = ((EpiDataView)(this.oTrans.EpiDataViews[“DMRHead”]));

When you want to reference the DMRNum, you’ll look at

ValueIn = (int)_edvDMRHead[“DMRNum”];

1 Like

So what if the called form (Form 2) was not modal and you wanted to make it behave like as is you had performed an Open With from the Calling form.

Example, calling the picking list from a button the sales order, you pass in the ordernum as a parameter for pick list print, but instead of closing the print dialog, you click back on the SO form and either enter in another SO number or select one from the navigator, changing the SO header and its details how would you reflect that SO number change as a parameter in the picking list print filter tab?