LaunchFormOptions - Pass data one form to another

I want to pass some data from “Receipt Entry” to the “Print Tags” form. After doing some research it looks like I can use LaunchFormOptions to do this.

Seems like the example below is simple enough, but the “MenuID” for the form MtlTagForm doesn’t seem to have a menu ID.

LaunchFormOptions lfo = new LaunchFormOptions();
lfo.ContextValue = “Value from ShipDtl”;
ProcessCaller.LaunchForm(oTrans, “MENUID”, lfo);

image

image

Anyway I can pass PackSlip, PackLine, and OrderRelNum into the MtlTagForm? Or if the MtlTags already have this is there a way to call those values?

There is another signature for that method:
public static object LaunchForm(object Sender, string AssemblyName, object launchObject, bool returnVal)

You can pass Erp.UIRpt.MtlTags

Thanks Chris. Do you have an example using that method? Sorry still fairly new and learning.

I think the tricky part is in finding out what values will be expected by your report form.
And if you’ll also need custom value handling added to the called report form.

I don’t have an example for MtlTags handy… but if I remember, this one isn’t easy.
If you search for “lfo” or LaunchFormOptions" there are a lot of examples here that cover many common variations.

As for specifying the process key instead of a menu ID:

  • ProcessCaller.LaunchForm(oTrans, “Erp.UIRpt.MtlTags”,xxxxxx);

And here is discussion related to printing tags.
Possible option of creating your own custom BAQ report, calling with a button?

1 Like

Thanks. Yes, I’ve been searching online and found bits of information here and there. I just found one that closely resemblance what I’m trying to.

So that got me close to what I need, being able to pass a few parameter to the MtlTags form. The example shows a button click event. Do you know how I can trigger the same event but through the menu launching of “Print Tags”?

image

Oh just found toolbar click event. Will try that.

True, but my magic 8 ball says for v 10.2.100 it’s looking for
lfo.ValueIn = “partnum~desc~tranqty~format~uom~vendorNum~PONum~POLine~PORel~whCode~binNum”

Thanks Chris. That’s where I am now running into issue is passing the correct parameter to the MtlTags. I am getting “Index was outside the bounds of the array”.

So from my “Receipt Entry”, I pass the lfo.ValueIn similar to your example, plus my other parameters I am passing correct?

Then from the MtlTags form, the image you provided is what I put into the “FormLoad”?

No need, what I show is the base handling of the MtlTags for, it takes care of that already. (I should note the handling of the passed params depends on the calling screen… what I describe is handling when called from ReceiptEntry)

However, if you are wanting some different functionality, then you will need to write that handling on the MtlTags form. If this is the case, you can pass what ever data you want, so long as you handle it.

As a side bar, one handy thing I like to do is to make a class representing what I want to pass. Simple example below:

public class MyObj
{
  public string Job;
  public int Asm;
   //etc
}

//then make an instance:
var obj = new MyObj();
//set how you like
obj.Job = "DaJob";
obj.Asm = 999;

lfo.ContextValue = obj;


THEN....In receiving form (make sure you redefine class)
MyObj recObj = lfo.ContextValue;
//recObj.Job; heres the job, etc
//Do you logic based on vals here

I want to pass the value in txtPackingSlip, txtPackLine, and txtRelease textbox from the lines tab so that I can use it as a parameter for a BAQ to pull into the MtlTag form.

Right now as a test, I just put in the txtPackingSlip textbox. However, I am getting an error when trying to launch the MtlTag form.
image

If I click “OK”, then it opens up to MtlTag forms. The one on the left looks right, but then it also open the one on the right which I don’t know where the qty 2000 comes from.

This is expected because the form expects 11 params as I showed. Anything else will break it. Sounds like you need to use ContextValue and custom handling, similar to what I described above.

So here’s what I have so far. To defined the parameter, I would have to pull the value from Receipt Entry and build my string correct? Similar to how I am pulling the txtPackingSlip?

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 **
EpiTextBox PackNum;

public void InitializeCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
	// Begin Wizard Added Variable Initialization

	this.baseToolbarsManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
	// End Wizard Added Variable Initialization

	// Begin Wizard Added Custom Method Calls

	// End Wizard Added Custom Method Calls
	PackNum = (EpiTextBox)csm.GetNativeControlReference("c11269a3-cbea-4ba5-9446-8da971b92293");
}

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

	this.baseToolbarsManager.ToolClick -= new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
	// End Wizard Added Object Disposal

	// Begin Custom Code Disposal

	// End Custom Code Disposal
}

private string getParametersForMtlTags()
{
	string str = "~";
	StringBuilder builder = new StringBuilder(string.Empty);

	
	builder.Append(PackNum.Text);
	builder.Append(str);
	//more string building in here.....
	return builder.ToString();
}

public class FormImpersonator:ILaunch
{
	private	string _formname;
	private	object _session;

	public FormImpersonator(string form, object session)
	{
		_formname = form;
		_session = session;
	}

	public string WhoAmI
	{
		get {return _formname;}	
	}

	public object Session
	{
		get {return  _session;}	
	}
}


private void baseToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
{
	//MessageBox.Show(args.Tool.Key);  //Useful to identify what menu item is clicked
	if(args.Tool.Key == "PrintTagsTool")
	{
		// ** Place Event Handling Code Here **
		FormImpersonator hacky = new FormImpersonator("Erp.UI.App.ReceiptEntry",oTrans.Session);
		var lfo = new LaunchFormOptions();
		lfo.Sender = hacky;
		string currentVal = getParametersForMtlTags();
		lfo.ValueIn = currentVal;
		ProcessCaller.LaunchForm(hacky, "Erp.UIRpt.MtlTags", lfo);

		//MessageBox.Show(currentVal);
	}
}

}

Well, you are getting closer at least :slight_smile:

A few notes though:

  • You dont need to use the form impersonator, you are already calling from a valid form
  • Since you are calling from the ReceiptEntry, you CANNOT use ValueIn, as it is already used in the base processing (use ContextValue instead)

Thanks Chris. I took it off and not getting the first error anymore, but still not showing the right qty and displaying MtlTag forms twice. I am going to add in the parameters as you recommended. Thanks for all the help. Slowly getting their and learning. Thanks to all of you. I will update tomorrow if I am successful or still running into issues.

Hi Chris,

Quick question, if Receipt Entry is already passing some parameters to MtlTag form, how do I pull that from MtlTag do you know?

I think I can use the PONum, POLine, and PORel with my BAQ to get me what I need in the MtlTag form instead of the PackNum and Packline that I am going to try and pass from ReceiptEntry form.

that is opened because the menu item is passing those params in ValueIn, so you will need to hijack that button to stop that. ValueIn = null;

Not sure if I understand, but from the sound of it, I would still need to use the LaunchFormOptions from ReceiptEntry? If that’s the case, will try to add in the parameters that’s required by the MtlTags form.

Yes, you still need the LFO, but…

  • You cannot use ValueIn as its used by base processing on the MtlTags form
  • You must override the menu item the opens the MtlForm (because it sets that data in ValueIn which will be parsed by MtlTags
  • You will have to pass you params in ContextValue
  • In MtlTags, you will need to parse the ContextValue you passed and perform whatever actions you desire

Chris, thanks for the explanation. I had added the parameters, but I must be missing something else. It’s still opening the MtlTags form twice. Once with the right qty, and the other with the wrong qty.

I will post my code tomorrow and see if anyone can see what else I am doing wrong or provide some input.

Are you using the existing menu item to call the form, or did you create a new one?

If you are using the existing, you need to ensure the base code isnt called. I would assume you used a BeforeTookClick event, if so, set the args.Handled = true to stop the base code.