Adding a column to a grid that is not in the collection

I am trying to add the promise date of a PO to the related>PO’s tab in Project Entry. I followed some tutorials and I got some code that seems very close to working but doesn’t. It makes the column for promise date but doesn’t populate it with anything. Here is the code I wrote. The lines commented out are other things I tried that don’t work either but could have been in the right direction. (I also took out the wizard lines to make it more compact here)

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
{
Ice.Lib.Framework.EpiUltraGrid myGrid;
BOReaderImpl myReader;

public void InitializeCustomCode()
{
	myGrid = (Ice.Lib.Framework.EpiUltraGrid)csm.GetNativeControlReference("d2eba51d-bbd6-468d-a067-541c2e8533d6");
	myGrid.DisplayLayout.Bands[0].Columns.Add("PromiseDate", "Promise Date");
	myGrid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(grdMatLst_InitializeRow);
	myReader = WCFServiceSupport.CreateImpl<Ice.Proxy.Lib.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["PONum"].Value.ToString()))
	if(((int)e.Row.Cells["PONum"].Value)>0)
	{
		DataSet ds = myReader.GetList("PromiseDate","PONum='"+e.Row.Cells["PONum"].Value.ToString()+"'","PromiseDate");
		//DataSet ds = myReader.GetList("Erp:BO:UOMSearch","","UOMCode");
		//DataSet ds = myReader.GetRows("PromiseDate","PO='"+e.Row.Cells["PO"].Value.ToString()+"'","PromiseDate");
		if(ds.Tables[0].Rows.Count>0)
			e.Row.Cells["PromiseDate"].Value= ds.Tables[0].Rows[0]["PromiseDate"];
	}
}

public void DestroyCustomCode()
{
	myGrid.InitializeRow -= new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(grdMatLst_InitializeRow);
	myReader = null;
}

}

The code compiles fine and looks similar to what other people have done so it seems like I’m missing something small. Does anyone know where I’m going wrong?

Thanks,
Brian

edit: I saw someone had gotten something similar to what I am trying to achieve with a BAQDataView but I didn’t have Ice.Lib.Broadcast so I couldn’t use the publish/subscribe commands.

You want to use a BAQDataView … doing it this way is extremely slow since you are doing a lookup on the DB for each row. There is an example of doing with a BAQDataView here

1 Like

I actually saw that post but I couldn’t use Ice.Lib.Broadcast.
I tried adding it as an assembly reference but the closest thing I found was Ice.Lib.BroadcastTower.dll and it was already referenced.

You don’t need to reference anything just add the using… (If you are in 10)

hmm well it worked this time. maybe I was capitalizing the statement incorrectly. Either way, I’ll try the method you posted.

I implemented the BAQ view but when I open the customization it says an exception has been thrown and that length cannot be less than zero.
The line that causes the error is oTrans.PublishColumnChange(pubBinding, “MyCustomPublish”);
my pubBinding is “ProjectPO”
also do you know which .dll file has otrans information in it?

oTrans “information” is unique to each transaction. oTrans is an object of Type EpiTransaction from EpiClientLib.
That Error could be cause there is no publisher for PRojectPO? I’d have to see the rest of the code.

here’s the rest of the code in the method. ProjectPO is the name of the EpiBinding for the grid in project entry>related>POs

public void CreatePOBAQView()
{
baqViewPOs = new BAQDataView(“ProjectEntryPOView”);
oTrans.Add(“ProjectEntryPOViewBAQ”,baqViewPOs);

	string pubBinding = "ProjectPO";
	IPublisher pub = oTrans.GetPublisher(pubBinding);
	if(pub==null)
	{
		oTrans.PublishColumnChange(pubBinding, "MyCustomPublish");
		pub = oTrans.GetPublisher(pubBinding);
	}

	if(pub !=null)
		baqViewPOs.SubscribeToPublisher(pub.PublishName, "PORel_ProjectID");
}

Your binding needs to be specific to dataView.Field…ProjectPO isn’t a dataview.Field… It should be

“Table.Field”

I see what I was doing wrong. so the code works, when I open the customization there are no errors, it shows the correct columns in my grid… but the POs aren’t getting filled in. the BAQ is just returning any results with a project ID assigned on the release level.

Your Publish / Subscribe isn’t working right… you should probably Publish Subcribe to Project.ProjectID and not the POProject view…
What does your whole code look like?

I had changed it to Project.ProjectID before my last post, sorry I wasn’t clear about that.
// **************************************************
// Custom code for ProjectEntryForm
// Created: 3/8/2017 2:08:48 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.Contracts;
using Ice.Core;
using Ice.Proxy.Lib;
using Ice.Lib.Broadcast;

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 **
BAQDataView baqViewPOs;
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

	CreatePOBAQView();
}

public void CreatePOBAQView()
{
	baqViewPOs = new BAQDataView("ProjectEntryPOView");
	oTrans.Add("ProjectEntryPOViewBAQ",baqViewPOs);

	string pubBinding = "Project.ProjectID";
	IPublisher pub = oTrans.GetPublisher(pubBinding);
	if(pub==null)
	{
		oTrans.PublishColumnChange(pubBinding, "MyCustomPublish");
		pub = oTrans.GetPublisher(pubBinding);
	}

	if(pub !=null)
		baqViewPOs.SubscribeToPublisher(pub.PublishName, "PORel_ProjectID");
}

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
}

}

That all looks right, did you re-bind your Grid to the new View?

I figured out what the issue was. One of my columns was due date and the PO’s attached to the project I was testing didn’t have due dates. Can I make it so it shows the BAQ results even if a field is empty?

Testing with 3836 didn’t work but 3837 did.
thats the BAQ from the designer btw

I mean the grid doesn’t care if the field is empty or not… if you want the PO to show even if there is no DUeDate just make sure that’s not a requirement within the BAQ

retested with 3836 and it worked sooo I’m just not going to question it as long as it keeps working.
Thank you for all of your help!

1 Like

A post was split to a new topic: Issue replacing native grid with BAQDataView