Sales Order Entry - AfterAdapter method GetByID fails on first attempt

Using the oTrans_ordAdapter_AfterAdapterMethod on the OrderHed table with the GetByID method fails on the first attempt. Works fine after that. It does not matter if you search for the sales order number or you type it in and tab out of the editor. It does not fire even though it shows up in a trace. Is there a better way to check when an order is loaded into the form? I tried epiViewNotication and ListChanged and could not get them to work either.

Epicor version 10.1.600.30

If you post some code maybe we can get a better perspective.

Not much to see:

private void oTrans_ordAdapter_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)
		{
            //If a Sales Order is loaded
			case "GetByID":

              CheckReceiptModifications();

			break;
		}

	}

CheckReceiptModifications checks OrderHed view to make sure it has a row then checks a UD table to see if a checkbox is checked. If the checkbox is checked, it displays a message letting the user know the receipt has been modified.

What im trying to establish how do you know it doesn’t fire? I use GetByID as well in AfterAdapterMethod without a problem on 10.1.500.47 and 10.2.300.17.

I assume you either used a debugger or uncommented the EpiMessageBox.Show Line to see which Methods show up in a MsgBox.

Perhaps it fires and CheckReceiptModifications() doesn’t do its job?

I am surprised that ListChanged doesnt fire.

Yes, I uncommented the epiMessageBox.Show to verify. Also, the ListChanged event fires four times but all four of the ListChanged events show the OrderHed view has no rows. The ListChanged type all four times is ‘Reset’.


	private void OrderHed_DataView_ListChanged(object sender, ListChangedEventArgs args)
	{
		// ** Argument Properties and Uses **
		// OrderHed_DataView[0]["FieldName"]
		// args.ListChangedType, args.NewIndex, args.OldIndex
		// ListChangedType.ItemAdded, ListChangedType.ItemChanged, ListChangedType.ItemDeleted, ListChangedType.ItemMoved, ListChangedType.Reset
		// Add Event Handler Code
        MessageBox.Show("ListChanged " + args.ListChangedType.ToString());
        CheckReceiptModifications();
	}


    private void CheckReceiptModifications()
    {
         EpiDataView edv = (EpiDataView)(oTrans.EpiDataViews["OrderHed"]);
MessageBox.Show("Does OrderHed have a row? " + edv.HasRow.ToString());
         //And the sales order has data
         if (edv.HasRow)
         {

I finally used the EpiViewNotication Initialize event with a counter plus edv.HasRow to get it to fire at the right time. It works but not optimal.


	// Add Custom Module Level Variables Here **
        int InitializeCounter = 0;  

private void edvOrderHed_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
    // ** Argument Properties and Uses **
    // view.dataView[args.Row]["FieldName"]
    // args.Row, args.Column, args.Sender, args.NotifyType
    // NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow,  etc.
    if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
    { 
          //This event fires at least twice after there is a row in the OrderHed
          // view so use this counter to stop it from displaying a message from 
          // the CheckReceiptModifications() function.
          InitializeCounter = InitializeCounter + 1;

          if (InitializeCounter < 400)
          {
             CheckReceiptModifications();
          }
         if (InitializeCounter > 400)
          {
            InitializeCounter = 0;
          }
    }
}


    private void CheckReceiptModifications()
    {
         EpiDataView edv = (EpiDataView)(oTrans.EpiDataViews["OrderHed"]);

         //And the sales order has data
         if (edv.HasRow)
         {
           //Set this to 400 so the epiViewNotication does not send
          // the message twice
           InitializeCounter = 400;

I use a global variable “Order” where under EpiviewNotification Initialize event, if the variable does not equal the current row order number value, I would replace my variable with current row order number and proceed with my code.
If they are the same my code is not visited, thus only used once.

Pierre

1 Like

Using the Sales Order number as you stated works well. Thanks!