Material Tags and Passing Data

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)

Just a wild guess, but maybe ContextValue is null when you’re calling ToString() on it. Try launching the material tags form with the debugger and see where it throws the exception.

Well, it seems after debugging (selecting the MtlTags customization and clicking on Debug in Visual Studio) that, indeed like you said, the ContextValue is null. This confuses me as there is a pack slip number populated on the receipt entry screen when the MtlTag screen is called.

image

Update!

I discovered that the customization for the Receipt Entry screen was not associated in Menu Maintenance! I do not know why or how both the Receipt Entry and Material Tags forms had their customizations disassociated from them. At any rate, they both are invoked now and the pack slip number is populating in {callContextBpmData.ShortChar01}!!! Thank you so much for your patience and help through this Tanesh. I have learned a lot! Happy Holidays!

Hi Tanesh:

Just wanted to say Thank You again for all your help!

I have implemented the customization in our production environment and everything is working as expected. I have learned a great deal through this experience and look forward to applying it to other projects in the future!

Cheers,
James

Happy new year, James!

I’m glad to hear you got it working. Figuring this out was a massive pain back when I first did this, so I’m really happy that I could help you out.

You most certainly did and I am ever so grateful and indebted to you.

Happy New Year!!!

I worked through this process myself and I distilled it down to a set of steps I’ve written out for posterity.
After a tweak to BuildMtlTagParams, setIncomingParams is working for me, I’m on 10.2.200. The credit goes to jarrington and tmanjrekar. Thanks for the post!

Steps to get pack slip into CallContextBpmData

a. Create Material Tag Customization

  1. Turn on Developer Mode
  2. Open Receipt Entry
  3. Choose a PO and pack slip
  4. Go to Actions > Print Tags
  5. Wait for the Mtl tags form to open
  6. Go to Tools > customization
  7. Load the code in the “PrintTagCustomization.cs” file into the script editor
  8. Compile, save, and close
  9. Turn off Developer Mode
  10. Restart Epicor client.

b. Create “Material Tag” Process in Menu Maintenance

  1. Open Menu Maintenance
  2. Click on the “Processes” folder.
  3. Click “New group”
  4. Enter a menu ID. This guide will use “UD1000”. Any unique value is fine.
  5. Set Name to “Material Tag”.
  6. Choose the Program “Erp.UIRpt.MtlTags.dll”
  7. Choose the customization created in section a.
  8. Save and close

c. Create Process

  1. Open “Process Calling Maintenance”
  2. Set Called Process Reference to: “Erp.UIRpt.MtlTags”
  3. Set Called From to “Erp.UI.ReceiptEntry”
  4. Set Menu ID to use “UD1000”

d. Create Receipt Entry Customization

  1. Turn on Developer Mode
  2. Go to Tools > Customization
  3. Load the code in the “ReceiptEntryCustomization.cs” file into the script editor
  4. In the script editor, replace the menu ID with your menu ID, if different.
  5. In the script editor, replace the GUID for the Pack Slip Textbox if different.
  6. Compile, save, and close.
  7. Turn off Developer Mode.
  8. Restart Epicor client.

e. Activate Customization in Menu Maintenance

  1. Open Menu Maintenance
  2. Go to Main Menu > Material Management > Shipping / Receiving > General Operations > Receipt Entry
  3. Select the customization created in section d.
  4. Save and close

f. Resolving setIncomingParamsFromReceiptEntry Errors
If you encounter the error, “Index was outside the bounds of the array, caught in MtlTags.Transaction.setIncomingParamsFromReceiptEntry”, follow this.

  1. Turn on Developer Mode
  2. Open Receipt Entry
  3. Go to Tools > Customization
  4. In the script editor, the BuildMtlTagParams() method may need to be changed.
  5. To solve this, we must decompile the material tag code to know what information it expects to be sent from the Receipt Entry screen using a decompiler (e.g. DotPeek).
  6. Install a decompiler and load the dll from the Epicor Install path: Epicor\ERP10.2Client\Client\Erp.UIRpt.MtlTags.dll
  7. Select the namespace: Erp.UI.Rpt.MtlTags
  8. Select the type: Transaction
  9. Open method: setIncomingParamsFromReceiptEntry
  10. This method definition contains the “inverse” function to BuildMtlTagParams in the Receipt Entry Customization code.
  11. Modify the BuildMtlTagParams() method in the Receipt Entry Customization so that the parameters correspond to what is found in the setIncomingParamsFromReceiptEntry decompiled method.
  12. Save the customization and close.
  13. Turn off developer mode.
  14. Restart Epicor and test again.

PrintTagCustomization.cs (1.8 KB) ReceiptEntryCustomization.cs (5.9 KB)

2 Likes

Hi,

Might be silly question, but how do you know that the syntax has to be opts.ValueIn = and delimited by “~”. I am pretty sure that on e9 it was possible to pass data in ContextValue and delimiter was “;”.