Quote Customization - AfterAdapterMethod Not Running

I started a new customization from the Opportunity/Quote Entry window (started with just the base form). All I have done is added an AfterAdapterMethod as oTrans_adapter_AfterAdapterMethod with a case statement for “GetCustomerInfo”. I want to use this area to call a MessageBox. When I ran the trace, I see the method “Quote.GetCustomerInfo()” being called when a CustID is entered on the form, and a post-processing BPM will fire from that method. However, the AfterAdapterMethod in the customization does not work. Any ideas on this one? Here’s the customization’s code:

// **************************************************
// Custom code for QuoteForm
// Created: 9/18/2017 11:06:00 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Epicor.Mfg.BO;
using Epicor.Mfg.UI;
using Epicor.Mfg.UI.Adapters;
using Epicor.Mfg.UI.Customization;
using Epicor.Mfg.UI.ExtendedProps;
using Epicor.Mfg.UI.FormFunctions;
using Epicor.Mfg.UI.FrameWork;
using Epicor.Mfg.UI.Searches;

public class Script
{
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **

private EpiBaseAdapter oTrans_adapter;
// End Wizard Added Module Level Variables **

// Add Custom Module Level Variables Here **

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

	this.oTrans_adapter = ((EpiBaseAdapter)(this.csm.TransAdaptersHT["oTrans_adapter"]));
	this.oTrans_adapter.AfterAdapterMethod += new AfterAdapterMethod(this.oTrans_adapter_AfterAdapterMethod);
	// End Wizard Added Variable Initialization

	// Begin Wizard Added Custom Method Calls

	// End Wizard Added Custom Method Calls
}

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

	this.oTrans_adapter.AfterAdapterMethod -= new AfterAdapterMethod(this.oTrans_adapter_AfterAdapterMethod);
	this.oTrans_adapter = null;
	// End Wizard Added Object Disposal

	// Begin Custom Code Disposal

	// End Custom Code Disposal
}

private void oTrans_adapter_AfterAdapterMethod(object sender, AfterAdapterMethodArgs args)
{
	// ** Argument Properties and Uses **
	// ** args.MethodName **
	// ** Add Event Handler Code **

	// ** Use MessageBox to find adapter method name
	// EpiMessageBox.Show(args.MethodName)
	switch (args.MethodName)
	{
		case "GetCustomerInfo":
			MessageBox.Show("This is where I want the Sticky Notes to show.");
			break;
		case "Update":
			break;
		default:
			break;
	}

	}
}

I would really recommend using the built in (and commented out) line above that will show the method name after it fires.
Uncomment the line EpiMessageBox.Show(args.MethodName) and change it to MessageBox.Show(args.MethodName).
This will show the correct name of the methods that fire.

It’s very likely a method name issue…

Aaron,

That’s the other odd part about this. When I uncomment that line, here are the results that I get:

When I click “New Quote”: GetNewQuoteHed
When I add the “CustID”: no messagebox, but the Quote.GetCustomerInfo() BPM still fires

I’m confused by this, to say the least. It seems as though the oTrans and Quote BO are not completely tied together. But why in the world would you ever want to reference the BO.Quote adapter from the Quote Form instead of using the oTrans?

So that means that adapter is not firing the after invoked event (not all do) you’ll have to find a different event to hang your hat on, unfortunately

So, if that adapter isn’t firing the BPM, and I have the “MessageBox.Show(args.MethodName)” showing for the oTrans_adapter, then there is no method being called from the oTrans at all when I enter add a CustID to the Quote?

Well the method is being called if it shows in the Trace… but its not firing an event in the UI that tells you it was fired. However BPM’s should still be called

If you are only looking to display the messagebox when the Quote is created, try After Field Change on the QuoteHed.CustID field.