Material Tags and Passing Data

James, delete this line in MtlTagsForm_Load:

EpiDataView callContextBpmDataView = (EpiDataView) this.oTrans.EpiDataViews[(object) "CallContextBpmData"];

Then in the same method, replace all instances of “callContextBpmDataView” with “edvCallContextBpmData”

Thank you Tanesh. Now that I have made the changes you suggested, I am now receiving a different error message.

Compiling Custom Code ... 

----------errors and warnings------------

 Error: CS1061 - line 63 (197) - 'Ice.Lib.Framework.EpiDataView' does not contain a definition for 'dataview' and no extension method 'dataview' accepting a first argument of type 'Ice.Lib.Framework.EpiDataView' could be found (are you missing a using directive or an assembly reference?)

 ** Compile Failed. **

As you can see from the coding in a prior message I do have the using Ice.Lib.Framework; invoked. Do I need another assembly reference?

I think it originates from

this.callContextBpmDataView.dataview

that’s in MtlTagsForm_Load.

It should be

this.callContextBpmDataView.dataView

I see that case is important in coding! Thank you!
I am receiving no compiling error messages now and I have finally reached the point where the {CallContextBpmData.ShortChar01} field is being populated. :grinning:
However, instead of inserting the actual Pack Slip number, it is inserting text that appears to be the name of an Assembly Reference. As you can see in the image below, I have used the native control reference for the txtKeyField (PackSlip). If I change it to opts.ContextValue = “txtKeyField”; then ‘txtKeyField’ is what populates in the {CallContextBpmData.ShortChar01} field. Any ideas?

Your ContextValue is being set to the EpiTextBox. It should be set to the EpiTextBox’s Text property to get the data actually stored in it.

Tanesh, can you clarify the syntax of the .Text property?

I have tried several configurations of it to set the opts.ContextValue in the ShowCustomMtlTags() but to no avail. Should I get the value of txtKeyField by using the GetNativeControlReference ID or is there a better way to acheive this?

GetNativeControlReference returns the control specified, which can be any control - a textbox, a checkbox, a label.

EpiTextBox txtPackSlip = (EpiTextBox)csm.GetNativeControlReference("guid goes here");

EpiTextBox is similar to the .NET TextBox control and exposes similar properties.

So to get the text from this control, you look at its Text property

string packSlip = txtPackSlip.Text;

 

This will get the job done, but it’s generally better to get the data from the control’s data source instead. So ideally, you should be doing something like this:

string packSlip = rcvDtlView.dataView[rcvDtlView.Row]["PackSlip"].ToString()

This is how we’re pulling data from the EpiDataView in BuildMtlTagParams(), so you can check that for more detail.

Tanesh:

I have edited the code for the ShowCustomMtlTags() and it compiles successfully. However, when I query the CallContextBpmData table in SQL, the ShortChar01 field is not populated with the PackSlip number. Below is my code:

	private void ShowCustomMtlTags()
	{
		LaunchFormOptions opts = new LaunchFormOptions();
		EpiDataView RcvDtlView = (EpiDataView)(oTrans.EpiDataViews["RcvDtl"]);
		string packSlip = RcvDtlView.dataView[RcvDtlView.Row]["PackSlip"].ToString();
		opts.IsModal = false;
		opts.ValueIn = BuildMtlTagParams();
		opts.ContextValue = packSlip;
		ProcessCaller.LaunchForm(oTrans, "UDMT01", opts);
	}

Could it be the case that I have wrong? I know how crucial case is in C#.

I think this

(EpiDataView)(oTrans.EpiDataViews["RcvDtl"])

should be changed to this

(EpiDataView)(oTrans.EpiDataViews["ReceiptRcvDtl"])

Tanesh:

Okay, I changed RcvDtl to ReceiptRcvDtl as you suggested above and it compiles successfully. I am still not seeing any information in the callContextBpmData.ShortChar01 field when I query it in SQL. Could it be in the Print Material Tags form’s customization that is not setting the value correctly due to case or wrong syntax? Below is the MtlTagsForm_Load() code. Do you see anything that stands out?

	private void MtlTagsForm_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code

			if (this.MtlTagsForm.LaunchFormOptions != null)
			{
				this.edvCallContextBpmData.dataView[this.edvCallContextBpmData.Row]["ShortChar01"] = this.MtlTagsForm.LaunchFormOptions.ContextValue.ToString();
			}
	}

From your screenshot above where you queried the table in SSMS and saw a value in ShortChar01 (the EpiTextBox control name), it seems like the material tags form is working okay. Unless you’ve made any changes to the form since then, I doubt that’s the problem.

I would open up the receipt entry customization in a debugger and verify that it’s actually getting the packslip value when the LaunchFormOptions object is being built.

Okay. Yes, I have made no changes to the Material Tags form. I will try your suggestion. Thank you very much.

Tanesh:

A couple of questions. I am new to debugging. Do you have a recommendation on a debugger. I see many out there available. Also, how do I find the receipt entry customization to debug? Is it located in the C:\ProgramData\Epicor<server name>\3.2.200.0<company>\CustomDLLs folder? Sorry to sound like such a neophyte!

I use Visual Studio. Just launch the screen through Customization Maintenance from Actions - Modify Customization (or by opening the customization using developer mode). When you get the screen which lets you pick a customization or launch the base form, check the “Debug in Visual Studio” checkbox and open your customization.

From there, it’s a fairly standard debugging process - setting breakpoints and inspecting values - for which you can find plenty of documentation online.

Thank you very much! I did not know about that checkbox! I’m sure it’s been there the whole time, I just never noticed it! :slight_smile:

Tanesh:

Why would the ‘Debug in Visual Studio’ be grayed out?

I discovered that the version of Visual Studio I was using with Epicor 10.2.200.13 did not work. I installed Visual Studio 2015 and the ‘Debug in Visual Studio’ checkbox was no longer grayed out.

Hi Tanesh:

This is where I am at. I have managed to debug the Receipt Entry Customization and it is setting the ContextValue for the pack slip number and passing it to the Print Material Tags form. When I then ran debugging on the MtlTags customization, I could see that the pack slip number was there in the LaunchFormOptions; however, for some reason this line of code is not placing the pack slip number in to “ShortChar01” because when I run a SELECT statement in SQL on the callContextBpmData table, that column is blank. Any ideas?

I have an update to this. When I run the customization through the debugging process all the way to the end and generate the labels, I can see the pack slip number is populated in callContextBpmData.ShortChar01 in my SELECT statement. HOWEVER, when I generate the labels without debugging, it does not populate the pack slip number in to ShortChar01.

I hope that makes sense!

Can you confirm that your material tags customization is called when you generate the tags through receipt entry? Running the receipt entry screen in dev mode should show you the menu ID of the process being called, and you can verify that it’s linked to your material tags customization.

Indeed, the customization was not set in Menu Maintenance for the Mtl Tags form. Not sure how it got removed, but I put it back.

Now when the Mtl Tag dialog is launched from receipt entry, I immediately get an error message before the form even appears. Are you familiar with this message? When I click on OK, the Mtl Tag form then appears and when I generate labels, the ShortChar01 field is not being populated.

image

Detail is as follows:

Application Error

Exception caught in: mscorlib

Error Detail 
============
Message: Exception has been thrown by the target of an invocation.
Inner Exception Message: Object reference not set to an instance of an object.
Program: CommonLanguageRuntimeLibrary
Method: InvokeMethod

Client Stack Trace 
==================
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Ice.Lib.Customization.CustomScriptMethodInvoker.InvokeScriptMethod(MethodInfo scriptMethod, Object[] parameters)
   at Ice.Lib.Customization.CustomScriptMethodInvoker.InvokeCustomFormLoadIfExists(String methodName, Object sender, EventArgs e)
   at Ice.Lib.Customization.CustomScriptManager.<>c__DisplayClass103_0.<OnCustomCodeFormLoad>b__0()
   at Ice.Lib.Customization.CustomScriptManager.TryActionShowExceptionBoxOrLogVerificationErrorIfException(Action action, String exceptionBoxTitle)

Inner Exception 
===============
Object reference not set to an instance of an object.



   at Script.MtlTagsForm_Load(Object sender, EventArgs args)