All,
OK, so this has been covered seven ways from Sunday, and I think I have reviewed all of the relevant posts and am still stuck.
I have added a UD Field (cBuyerDueDate_c) to the PO Release table (Erp.PORel). I want to add it to the grid views on the Buyer’s Workbench. @josecgomez has a great YouTube video on how do do this by replacing the existing grid bindings with a BAQ result set (thanks Jose!). After replacing three of the PO related grids on the Workbench using this method, I realized that they no longer sync with the Tree View–the user cannot select the PO on the Tree View and have it navigate to the same PO on the grid view. I also discovered that the PO Entry… button no longer opened the selected PO
(Epicor standard functionality)
I figured that I might be able to replace the existing button with a custom button and get that to work with the new grid views, but fixing the tree view appears to be a rabbit hole. I could ask my users to ignore the tree view and use right-click/Open With… and I might resort to that. I thought, however, that I would at least try the other suggested method, which is to create a new column in the grid and use the BOReader assembly reference to populate it on the fly. I realize from the feedback on this site, that this method is inefficient and may have performance issues.
The code compiles and the form loads without error. The column gets added to the grid, but it is not populating.
I think this is the section of the custom code that is not working as intended:
private void grdLatePOR_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
if(!String.IsNullOrEmpty(e.Row.Cells["PONum"].Value.ToString()) && !String.IsNullOrEmpty(e.Row.Cells["POLine"].Value.ToString()) && !String.IsNullOrEmpty(e.Row.Cells["PORelNum"].Value.ToString()))
{
DataSet ds = _boReader.GetRows("Erp:BO:PORel","PONum='" + e.Row.Cells["PONum"].Value.ToString()+ "' and POLine='" + e.Row.Cells["POLine"].Value.ToString()+ "' and PORelNum='" + e.Row.Cells["PORelNum"].Value.ToString() + "'","cBuyerDueDate_c");
if(ds.Tables[0].Rows.Count > 0 )
e.Row.Cells["cBuyerDueDate_c"].Value = ds.Tables[0].Rows[0]["cBuyerDueDate_c"];
}
}
When I debug this in Visual Studio, I get a Null Exception error on the DataSet ds =… line. Because the UD field is a date value, it is NULL in some cases, and I am guessing that I need to handle that in the code–not sure how to do that. It may also be that I am not clear no how to query the data correctly through _boReader.GetRows. I am a C# novice and could use some help on this.
For context, I have added these custom assembly references…
…and here is all of my custom code…
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;
using Ice.Core;
using Ice.Contracts;
using Erp.BO;
using Ice.BO;
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 **
EpiUltraGrid lateGrid;
BOReaderImpl _boReader;
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
lateGrid = (EpiUltraGrid)csm.GetNativeControlReference("7165b214-eac4-4184-8d1e-3c9770bfc022");
lateGrid.DisplayLayout.Bands[0].Columns.Add("cBuyerDueDate_c", "Buyer Date");
lateGrid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(grdLatePOR_InitializeRow);
BOReaderImpl _boReader = WCFServiceSupport.CreateImpl<BOReaderImpl>((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.BOReaderSvcContract>.UriPath);
}
private void grdLatePOR_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
if(!String.IsNullOrEmpty(e.Row.Cells["PONum"].Value.ToString()) && !String.IsNullOrEmpty(e.Row.Cells["POLine"].Value.ToString()) && !String.IsNullOrEmpty(e.Row.Cells["PORelNum"].Value.ToString()))
{
DataSet ds = _boReader.GetRows("Erp:BO:PORel","PONum='" + e.Row.Cells["PONum"].Value.ToString()+ "' and POLine='" + e.Row.Cells["POLine"].Value.ToString()+ "' and PORelNum='" + e.Row.Cells["PORelNum"].Value.ToString() + "'","cBuyerDueDate_c");
if(ds.Tables[0].Rows.Count > 0 )
e.Row.Cells["cBuyerDueDate_c"].Value = ds.Tables[0].Rows[0]["cBuyerDueDate_c"];
}
}
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
lateGrid.InitializeRow -= new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(grdLatePOR_InitializeRow);
_boReader = null;
}
}
Thanks in advance for any pointers.
Regards,
Michael Thompson