Pass Parameters to Form

I am launching RMA Entry form and want to pass parameters to fill in columns based upon my selection from a Dashboard. I have the code to launch the form with a button and pass the parameters. I read and have deciphered in a few other posts that I need to have the responding form (RMA Entry) customized to know what to do with those parameters. I don’t have any idea where to start with that form.

Launch Code in Form:

	private void btnCreateNon_Conformance_Click(object sender, System.EventArgs args)
	{
	LaunchFormOptions lfo = new LaunchFormOptions();
	lfo.IsModal = false;
	lfo.SuppressFormSearch = true;
	System.Collections.Generic.Dictionary<string, string> mylist = new System.Collections.Generic.Dictionary<string, string>();
	mylist.Add("CustID", txtCustomer_CustID.Text); 
	//mylist.Add("CustID", "03061982");
	mylist.Add("RMANum", "0");
	mylist.Add("OrderNum", "1411");
	mylist.Add("OrderLine", "1");
	mylist.Add("OrderRel", "1");
	mylist.Add("actiontype", "NewRMA"); 
	string valuein = "RMA";	
	lfo.ValueIn = valuein;
	lfo.ContextValue = mylist;
	MessageBox.Show("ButtonC1Launch", txtCustomer_CustID.Text);
	ProcessCaller.LaunchForm(oTrans, "CRGO5000", lfo); 
	}

For the button, I would create the NonConformance first with the information first, and then the value in will be the new NonConformance that you created that passed into the lfo as Valuein.

Hi @skearney,

You have to declare and define a LaunchFormOptions Variable to receive the values.

private static LaunchFormOptions opts = <Your Form Name>.LaunchFormOptions;

Then you get values from opts on formload;

    if (opts != null && opts.ValueIn != null)
    {
    	string value = opts.ValueIn.ToString();
    }

Regards,
Zoher Ali

2 Likes

Okay, I tried that. Attached is a pic of my errors.

Add the form load event and then you can use code like this within it…

	private static void RMAProcForm_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code
		LaunchFormOptions opts = RMAProcForm.LaunchFormOptions;
	
	    if (opts != null && opts.ValueIn != null)
	    {
	    	string value = opts.ValueIn.ToString();
			MessageBox.Show(value);
	    }
	}
1 Like

Okay, so far I am passing value’s in but they aren’t doing anything. How do I tell the RMA form I want to create a new RMA and then enter the passed information in for Cust Num and Order Num?

// Custom code for RMAProcForm
// Created: 7/25/2018 3:51:52 PM
// **************************************************

extern alias Erp_Contracts_BO_RMAProc;
extern alias Erp_Contracts_BO_SalesOrder;
extern alias Erp_Contracts_BO_RMADisp;
extern alias Erp_Contracts_BO_Customer;
extern alias Erp_Contracts_BO_ShipTo;
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_OrderRelSearch;

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.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 static class Script
{
private static EpiTextBox txtCustomerCustID;
private static EpiTextBox txtKeyField;
private static EpiTextBox txtOrderNum;
private static EpiTextBox txtOrderLine;
private static EpiTextBox txtRelease;

	// ** 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
		txtCustomerCustID = (EpiTextBox)csm.GetNativeControlReference("83061afd-f368-416f-9e6f-bde3c6a2f666");
		txtKeyField = (EpiTextBox)csm.GetNativeControlReference("ffa1f4c3-de16-4a3d-a307-340ff1389f43");
		txtOrderNum = (EpiTextBox)csm.GetNativeControlReference("46567b2e-6bc0-4967-be35-a0ec6843838f");
		txtOrderLine = (EpiTextBox)csm.GetNativeControlReference("f9fd5a44-5540-4adc-9fe1-b6aea605e722");
		txtRelease = (EpiTextBox)csm.GetNativeControlReference("292add1b-3719-46ba-9a14-64103f29eece");

		// End Wizard Added Custom Method Calls

	}

	public static 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
		//txtCustomerCustID = (EpiTextBox)csm.GetNativeControlReference("83061afd-f368-416f-9e6f-bde3c6a2f666");

		// End Custom Code Disposal

private static void RMAProcForm_Load(object sender, EventArgs args)
	{
		LaunchFormOptions opts = RMAProcForm.LaunchFormOptions;
		string CustID = string.Empty;
		if (opts != null && opts.ContextValue != null && opts.ValueIn != null)
            {
                Type lfotype = opts.ContextValue.GetType();
                if(lfotype == typeof(System.Collections.Generic.Dictionary<string, string>))
                {
                    System.Collections.Generic.Dictionary<string, string> mylist = (System.Collections.Generic.Dictionary<string, string>)opts.ContextValue;
                    string fldname = "";
                    string fldvalue = "";
                    foreach (System.Collections.Generic.KeyValuePair<string, string> pair in mylist)
                    {
                        fldname = pair.Key;
                        fldvalue = pair.Value;
                        switch (fldname)
                        {
                            case "CustID":
                                {
                                    txtCustomerCustID.Text = fldvalue;
                                    break;
                                }
							 case "RMANum":
                                {
                                     txtKeyField.Text = fldvalue;
                                    break;
                                }
							 case "OrderNum":
                                {
                                     txtOrderNum.Text = fldvalue;
                                    break;
                                }
							 case "OrderLine":
                                {
                                     txtOrderLine.Text = fldvalue;
                                    break;
                                }
							 case "OrderRel":
                                {
                                     txtRelease.Text = fldvalue;
                                    break;
                                }
                            
                            
                            default:
                                {
                                    break;
                                }
                        }
                    }

					MessageBox.Show(txtCustomerCustID.Text + ", " + txtKeyField.Text + ", " + txtOrderNum.Text + ", " + txtOrderLine.Text + ", " + txtRelease.Text);
                }
			}
		else 
			{
				MessageBox.Show("Order number was not entered"); CustID = ""; return;  
			} 
}
}




	```

At what point is it not working? Have you verified you’re getting past your initial context value check?

private void UD01Form_Load(object sender, EventArgs args)
{
  if(UD01Form.LaunchFormOptions !=null)
  {
    dsInput = (DataSet)UD01Form.LaunchFormOptions.ContextValue;
    if(dsInput !=null)
    {
      //do stuff with the now filled out dsInput
    }
  }
}

Me thinks you may have added the FormLoad code manually (and therefore not the events). Did you use the wizard to add the FormLoad event?

Also, I see you are setting the textbox.text values, you should look at the epibinding of those controls and use the correct EpiDataViews/fields instead so the “epiMagic” occurs (like loading records, etc)

Okay, I am finally back to working on this. I have a form that I am passing parameters from. My code in that form:

private void btnCreateNon_Conformance_Click(object sender, System.EventArgs args)
	{
	LaunchFormOptions lfo = new LaunchFormOptions();
	lfo.IsModal = true;
	lfo.SuppressFormSearch = true;
	System.Collections.Generic.Dictionary<string, string> mylist = new System.Collections.Generic.Dictionary<string, string>();
	mylist.Add("OpenRMA", "true");
	mylist.Add("CustID", "03061982");
	mylist.Add("CustNum", "24989");
	mylist.Add("RMANum", "0");
	mylist.Add("OrderNum", "1411");
	mylist.Add("OrderLine", "1");
	mylist.Add("OrderRel", "1");
	string valuein = "GetNewRMA";
	lfo.ValueIn = valuein;
	lfo.ContextValue = mylist;
	lfo.CallBackMethod = MyNonConCallBackHandler;
	ProcessCaller.LaunchForm(oTrans, "CRGO5000", lfo); 
	}

This is the code of the form receiving the information:

private static void RMAProcForm_Load(object sender, EventArgs args)
	{
		LaunchFormOptions opts = RMAProcForm.LaunchFormOptions;
		string CustID = string.Empty;
		if (opts != null && opts.ContextValue != null && opts.ValueIn != null)
            {
                Type lfotype = opts.ContextValue.GetType();
                if(lfotype == typeof(System.Collections.Generic.Dictionary<string, string>))
                {
					oTrans.GetNew();
					string value = opts.ValueIn.ToString();
					MessageBox.Show(value);
					MessageBox.Show("Start of Launch");
                    System.Collections.Generic.Dictionary<string, string> mylist = (System.Collections.Generic.Dictionary<string, string>)opts.ContextValue;
              
					string fldname = "";
                    string fldvalue = "";
                    foreach (System.Collections.Generic.KeyValuePair<string, string> pair in mylist)
                    {
                        fldname = pair.Key;
                        fldvalue = pair.Value;
                        switch (fldname)
                        {
                            case "CustID":
                                {
									MessageBox.Show("CustID");
                                    txtCustomerCustID.Text = fldvalue;
                                    break;
                                }
							case "CustNum":
							{
								break;
							}
							 case "OrderNum":
                                {
                                     txtOrderNum.Text = fldvalue;
                                    break;
                                }
							 case "OrderLine":
                                {
                                     txtOrderLine.Text = fldvalue;
                                    break;
                                }
							 case "OrderRel":
                                {
                                     txtRelease.Text = fldvalue;
                                    break;
                                }
                            
                            
                            default:
                                {
                                    break;
                                }
                        }
                    }

					MessageBox.Show(txtCustomerCustID.Text + ", " + txtKeyField.Text + ", " + txtOrderNum.Text + ", " + txtOrderLine.Text + ", " + txtRelease.Text);
                }
			}
		else 
			{
				//MessageBox.Show("Order number was not entered"); CustID = ""; return;  
			} 
}
}

I get the following when I click my button to launch the form: Get New RMA, Then another message box of CustID, then another message box of 03061982, 0,1411,1,1. It actually creates a new RMA but then it doesn’t enter in the Customer ID into the text box. Any ideas?

1 Like

I got this passing values into text boxes. For some reason I can’t get the Epicor field to accept values. Do I need to do something with it so it can accept values?