Classic - Input array is longer than the number of column in this table

This is a Classic customization in Purchase Advisor that pulls in a UD field from PO Line. I suffered many headaches getting it working, but then I installed it in Prod (both have the same UD fields) and it threw this error during runtime.
Then I went back to Test and did another test and I got the same error.
I don’t understand what changed or why I wasn’t getting this error before, nor how to fix it. I Test the Code and it compiles fine.
I thought it may have been client cache so I cleared that and logged back in… same error.
I did something similar in PO Suggestions to pull in a UD field from Requisition Lines.. and that works fine.. still.
I checked that my Referenced Assemblies are still there:

  • Erp.Adapters.PO
  • Erp.Contracts.BO.PO

Here is my code:

Code
// **************************************************
// Custom code for PurchaseAdvisorEntryForm
// Pull UD field Character02 from PO lines
// **************************************************

using System;
using System.ComponentModel;
using System.Data;
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 class Script
{
    // Module Level Variables
    private EpiDataView edvPurchased;
    private POAdapter poAdapter;

    public void InitializeCustomCode()
    {
        // Get the PurchasedBefore EpiDataView
        this.edvPurchased = (EpiDataView)oTrans.EpiDataViews["PurchasedBefore"];
        this.edvPurchased.EpiViewNotification += new EpiViewNotification(this.edvPurchased_EpiViewNotification);

        // Add column for the UD field
        DataColumn dc = new DataColumn();
        dc.ColumnName = "PO_Character02";
        dc.Caption = "Deliver To";
        edvPurchased.dataView.Table.Columns.Add(dc);
        edvPurchased.dataView.Table.Columns["PO_Character02"].ExtendedProperties["ReadOnly"] = true;

        // Initialize POAdapter
        poAdapter = new POAdapter(oTrans);
        poAdapter.BOConnect();
    }

    public void DestroyCustomCode()
    {
        edvPurchased.EpiViewNotification -= new EpiViewNotification(this.edvPurchased_EpiViewNotification);
        edvPurchased = null;

        if (poAdapter != null)
        {
            poAdapter.Dispose();
            poAdapter = null;
        }
    }

    private void edvPurchased_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
    {
        if (args.Row < 0) return;

        for (int i = 0; i < edvPurchased.dataView.Table.Rows.Count; i++)
        {
            DataRow row = edvPurchased.dataView.Table.Rows[i];

            // Only process rows with a PO number and line, and where our column is empty
            if (!string.IsNullOrEmpty(row["PONum"].ToString()) &&
                !string.IsNullOrEmpty(row["POLine"].ToString()) &&
                string.IsNullOrEmpty(row["PO_Character02"].ToString()))
            {
                string poNum = row["PONum"].ToString();
                int poLine = Convert.ToInt32(row["POLine"]);

                try
                {
                    // Clear previous PO data
                    poAdapter.ClearData();

                    // Load the PO
                    poAdapter.GetByID(poNum);

                    // Find the matching PO detail line directly (UD fields are already here)
                    DataRow poDetailRow = null;
                    foreach (DataRow detailRow in poAdapter.POData.PODetail.Rows)
                    {
                        if (Convert.ToInt32(detailRow["POLine"]) == poLine)
                        {
                            poDetailRow = detailRow;
                            break;
                        }
                    }

                    // Populate grid column
                    row.BeginEdit();
                    if (poDetailRow != null && poDetailRow.Table.Columns.Contains("Character02"))
                        row["PO_Character02"] = poDetailRow["Character02"].ToString();
                    else
                        row["PO_Character02"] = "No DeliverTo";
                    row.EndEdit();
                }
                catch (Exception ex)
                {
                    // In case of error, fill with message
                    row.BeginEdit();
                    row["PO_Character02"] = "Error: " + ex.Message;
                    row.EndEdit();
                }
            }
        }
    }
}