Sheepish post here. Right answer is to replace the grids with a BAQ per @josecgomez’s guide:
Wrong answer is to spend all day cobbling together code to add the columns to the grids. There are ~50 posts on how to do it the wrong way. And they are all outdated; BOReader is used differently now. Here are some decent posts FFR:
And here is the code I came up with, if anyone else wants it…
// **************************************************
// Custom code for BWForm
// Created: 5/4/2022 1:53:14 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
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;
using Ice.Proxy.Lib; //for BOReader
public class Script
{
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
private BOReaderImpl _boReader;
EpiUltraGrid ugdLate; //ugdLate 7165b214-eac4-4184-8d1e-3c9770bfc022
EpiUltraGrid ugdToday; //ugdToday 3232d1b3-82e5-475b-9d11-f230438a0036
EpiUltraGrid ugdThisWeek; //ugdThisWeek 1b6e1fdd-36dd-4a61-9333-061cca6b70d4
//EpiUltraGrid ugdFuture; //ugdFuture 5ad70697-7a4c-456c-8ef8-e5866dde0e0a
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
// End Wizard Added Custom Method Calls
//Add Qty Arrived columns to the 4 grids
ugdLate = (EpiUltraGrid)csm.GetNativeControlReference("7165b214-eac4-4184-8d1e-3c9770bfc022");
ugdToday = (EpiUltraGrid)csm.GetNativeControlReference("3232d1b3-82e5-475b-9d11-f230438a0036");
ugdThisWeek = (EpiUltraGrid)csm.GetNativeControlReference("1b6e1fdd-36dd-4a61-9333-061cca6b70d4");
//ugdFuture = (EpiUltraGrid)csm.GetNativeControlReference("5ad70697-7a4c-456c-8ef8-e5866dde0e0a");
ugdLate.DisplayLayout.Bands[0].Columns.Add("ArrivedQty","Arrived Qty");
ugdLate.DisplayLayout.Bands[0].Columns["ArrivedQty"].Hidden = false;
ugdLate.DisplayLayout.Bands[0].Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
ugdToday.DisplayLayout.Bands[0].Columns.Add("ArrivedQty","Arrived Qty");
ugdToday.DisplayLayout.Bands[0].Columns["ArrivedQty"].Hidden = false;
ugdToday.DisplayLayout.Bands[0].Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
ugdThisWeek.DisplayLayout.Bands[0].Columns.Add("ArrivedQty","Arrived Qty");
ugdThisWeek.DisplayLayout.Bands[0].Columns["ArrivedQty"].Hidden = false;
ugdThisWeek.DisplayLayout.Bands[0].Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
//Future table has noticeable performance hit, may be hundreds of POs in this list.
//ugdFuture.DisplayLayout.Bands[0].Columns.Add("ArrivedQty","Arrived Qty");
//ugdFuture.DisplayLayout.Bands[0].Columns["ArrivedQty"].Hidden = false;
//ugdFuture.DisplayLayout.Bands[0].Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
ugdLate.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(POList_InitializeRow);
ugdToday.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(POList_InitializeRow);
ugdThisWeek.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(POList_InitializeRow);
//ugdFuture.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(POList_InitializeRow);
_boReader = WCFServiceSupport.CreateImpl<BOReaderImpl>((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.BOReaderSvcContract>.UriPath);
}
private void POList_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
if(!String.IsNullOrEmpty(e.Row.Cells["PONum"].Value.ToString()))
{
string PONum = Convert.ToString(e.Row.Cells["PONum"].Value);
string POLine = Convert.ToString(e.Row.Cells["POLine"].Value);
string PORelNum = Convert.ToString(e.Row.Cells["PORelNum"].Value);
try {
//BO Reader call method for Epicor 2021.2.13...
DataSet ds = _boReader.GetRows("Erp:BO:PORelSearch"
,"PONum=" + PONum + " and POLine=" + POLine + " and PORelNum=" + PORelNum
, "SysRowID, ArrivedQty");
if(ds.Tables[0].Rows.Count > 0 )
e.Row.Cells["ArrivedQty"].Value = Convert.ToDecimal(Convert.ToDecimal(ds.Tables[0].Rows[0]["ArrivedQty"]).ToString("0.00"));
}
catch (Exception ex){
MessageBox.Show(ex.Message);
}
}
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
ugdLate.InitializeRow -= new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(POList_InitializeRow);
ugdToday.InitializeRow -= new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(POList_InitializeRow);
ugdThisWeek.InitializeRow -= new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(POList_InitializeRow);
//ugdFuture.InitializeRow -= new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(POList_InitializeRow);
_boReader = null;
}
}