Add Fields to Epicor Custom Grid

compiled failed when removing Core, so i have added it back and added what you suggested as well ‘Epicor.ServiceModel’, i have added my custom lines, the whole code complied fine now, however :):tired_face: my added field does not show any value

and this my code, (i am testing this code on Scheduling Resource Tracker Screen as i have manged to add the field but failed to bind it to Epicor DataBase)
// **************************************************
// Custom code for ResourceSchedForm
// Created: 27/09/2018 13:43:48
// **************************************************
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.Contracts;
using Ice.Core;
using Ice.Proxy.Lib;

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 **
Ice.Lib.Framework.EpiUltraGrid myGrid;
private 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

myGrid = (Ice.Lib.Framework.EpiUltraGrid)csm.GetNativeControlReference("87f88dc8-1b94-4324-ba83-583a2af5cbb9");
myGrid.DisplayLayout.Bands[0].Columns.Add("JobReleased", "Job Released");
myGrid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(grdList_InitializeRow);
BOReaderImpl _boReader = WCFServiceSupport.CreateImpl<BOReaderImpl>((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.BOReaderSvcContract>.UriPath);
}

private void grdList_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
	if (!String.IsNullOrEmpty(e.Row.Cells["JobNum"].Value.ToString()))
	{
	EpiDataView edv = oTrans.Factory("JobHead");
	DataSet ds = _boReader.GetRows("JobHead","JobNum='" +e.Row.Cells["JobNum"].Value.ToString()+ "'","JobNum");
	if(ds.Tables[0].Rows.Count > 0 )
	e.Row.Cells["JobNum"].Value = ds.Tables[0].Rows[0]["JobNum"];
	}
}

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
myGrid.InitializeRow -= new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(grdList_InitializeRow);
_boReader = null;
}

}

I assumed some of the code was good and just got it to compile. I can take another look to make sure it is functional

really appreciate your help Dan, i will add your name to ‘Epicor Gods List’ :):smiley:

i finish today for a week holiday, but i think this is the bit that i need to correct to bind my field to The Database, i will post my results once i succeed.

thank you very much Dan, have a nice weekend

Good stuff, guys! It’s over my head right now, but I’ll be using this as an example to follow to add the JobReleased column to the Multi Resource Scheduling Board.

Here is the updated code that will work. You could probably use GetList or GetRows for this. GetList would get you some better performance.

// **************************************************
// Custom code for ResourceSchedForm
// Created: 9/28/2018 8:47:46 AM
// **************************************************
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 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 myGrid;
	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
		myGrid = (EpiUltraGrid)csm.GetNativeControlReference("87f88dc8-1b94-4324-ba83-583a2af5cbb9");
		myGrid.DisplayLayout.Bands[0].Columns.Add("JobReleased","Job Released");
		myGrid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(grdMatLst_InitializeRow);
		_boReader = WCFServiceSupport.CreateImpl<BOReaderImpl>((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.BOReaderSvcContract>.UriPath);
	}

	private void grdMatLst_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
	{
		if(!String.IsNullOrEmpty(e.Row.Cells["JobNum"].Value.ToString()))
		{
			DataSet ds = _boReader.GetRows("Erp:BO:JobEntry","JobNum = '" + e.Row.Cells["JobNum"].Value.ToString() + "'","JobReleased");
			if(ds.Tables[0].Rows.Count > 0 ) 
			{
				e.Row.Cells["JobReleased"].Value = ds.Tables[0].Rows[0]["JobReleased"].ToString();
			}
		}
	}

	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
	}
}
4 Likes

@A.Baeisa - the path for the custom Assy reference should be to the file location on the server. Is E10 installed on the C drive of App Server?

Are you doing this development on client. If so, that path starting at C: probably isn’t the same as is on the app server.

This should not be the case.

He was not having a reference location problem - but more an issue of not having the right references. The client handles bringing in the assemblies from the proper location, unless you choose to go browse elsewhere which will not work. The path, once added, is smart enough to show whether it initially came from an E:\EpicorClient or now needs C:\EpicorClient

1 Like

Many Many Thanks @danbedwards
your code is working great, it slow the UI abit but this is acceptable compare to what we achieved, now i can use this ‘superduper’ code method technique to Add, link, and display any value on the Database to any Epicor Custom Tracker, really appreciate your support.

@ckrusen,
Thanks for your note, but @danbedwards already helped me to find these assy DLL files.

1 Like

Hi Dan,
i hope that you are ok, i am trying to apply this code to add a field (OrderRel.NeedByDate) to the Demand Custom Grid in Job Manager, the new issue in this case is passing three parameters not one i.e. OrderNum, OrderLine, and OrderRel, also could you please shed some light on GetByID LINQ structure here, as i menstioned before i have started teach myself C# in the past 6 months, and i am doing OK so far, so if you or any one on this great Forum know useful websites/documents/training material describing using Database C#.Net commands, i will be very appreciated to your advice,

Hi all
@hkeric.wci,
could any one help on this code issue ???
i am trying to apply this code to add a field (OrderRel.NeedByDate) to the Demand Custom Grid in Job Manager, the new issue in this case is passing three parameters not one i.e. OrderNum, OrderLine, and OrderRel, also could you please shed some light on GetByID LINQ structure here, as i menstioned before i have started teach myself C# in the past 6 months, and i am doing OK so far, so if you or any one on this great Forum know useful websites/documents/training material describing using Database C#.Net commands, i will be very appreciated to your advice,

I tried this code and it is giving me a null reference exception. Help.

it is an old post Chris, this issue has been resolved in many ways, check this post mate

OK, not getting the exception anymore but i can’t get this code to work
if (!string.IsNullOrEmpty(resource))
{
DataSet ds = _boReader.GetRows(“Erp:BO:Resource”, “ResourceID=’” + resource + “’”, “Description”);
if(ds.Tables[0].Rows.Count > 0)
{
row.Cells[“ResouceDesc”].Value = ds.Tables[0].Rows[0][“Description”];
}

I am trying to do this on the work queue.

Got this to work. It helps a lot if I spell thing correctly.

i prefer to use a dynamic query over BoReader, it is faster and easier, plenty of examples on the forum, this is one

1 Like

I use Dynamic Query when I need special data or when there exists possibility that a BSA will ask for different filtering.

I prefix the BAQs I use in Code with CODE-MyBAQIntent like CODE-GetLateAPInvoices.

I use BO Reader when its a flat file such as just get me a field from Customer, UDCode, Company Setting… Less dependencies.

2 Likes

many thanks @hkeric.wci
BO Reader (Get Rows) is very slow in the example i tried and posted, may be i need to optimise my code a bit

The nice thing about BOReader is that you can specify in the third arg/param what columns you want returned which in theory should speed it up :thinking:

Hi @tkoch
could you share a full example here please, mine on this thread was selected for one column as a parameter and was very slow compared to the Dynamic query