BOReader.GetRows

@josecgomez

I am trying to bring a couple of columns into a grid and saw your tutorial online (it was excellent). But I am having trouble with the first argument in GetRows. What is supposed to go there? You used APInvoice and ARInvoice but I did not see those anywhere else. Could you please advise?

What business object?

Epicor.Mfg.BO.POSuggChg

POSuggChg is what goes in the front (generally)

Thanks. Let me play around with that.

I am completely lost as to why I am not returning any values in the two columns I added. I know I am missing something, just don’t know what it is. Can anyone help? Thanks in advance.

// **************************************************
// Custom code for POSuggChgEntryForm
// Created: 7/23/2018 11:45:38 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Epicor.Mfg.BO;
using Epicor.Mfg.UI;
using Epicor.Mfg.UI.Adapters;
using Epicor.Mfg.UI.Customization;
using Epicor.Mfg.UI.ExtendedProps;
using Epicor.Mfg.UI.FormFunctions;
using Epicor.Mfg.UI.FrameWork;
using Epicor.Mfg.UI.Searches;
using Epicor.Mfg.Core;
using Epicor.Mfg.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 **

Epicor.Mfg.UI.FrameWork.EpiUltraGrid myGrid;
BOReader _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 = (Epicor.Mfg.UI.FrameWork.EpiUltraGrid)csm.GetNativeControlReference("b660f018-bd4c-4d5e-993e-62d6e8df81b5");
	myGrid.DisplayLayout.Bands[0].Columns.Add("MfgNumName", "Manufacturer");
	myGrid.DisplayLayout.Bands[0].Columns.Add("MfgPartNum", "Mfg Part");
	myGrid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(grdMatLst_InitializeRow);
	_boReader = new BOReader(((Session)oTrans.Session).ConnectionPool);
}

private void grdMatLst_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
	DataSet ds = _boReader.GetRows("POSuggChg","PONum='" + e.Row.Cells["PONum"].Value.ToString()+ "' and POLine='" + e.Row.Cells["POLine"].Value.ToString() + "'","MfgNumName, MfgPartNum");
	if (ds.Tables[0].Rows.Count>0)
		e.Row.Cells["MfgNumName"].Value = ds.Tables[0].Rows[0]["MfgNumName"];
		e.Row.Cells["MfgPartNum"].Value = ds.Tables[0].Rows[0]["MfgPartNum"];

}

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(grdMatLst_InitializeRow);
	_boReader = null;
}

}

I am thinking that I am not referencing the view correctly to get the data I need. I used DataTools to create a view to the data I need. Not sure how I need to get a hold of that data in the code above.

Any help is appreciated.

If PONum and POLine are Integer values, you should not use single quotes in your whereClause just like in SQL.

1 Like

By the way, shouldn’t the table by called SugPOChg with one “g” ?

Thanks for reviewing my code and catching the integer error. I fixed that but I am still not getting data back.

I used POSuggChg as that is the name of the view.

It’s works good. Few notes.

1- Youre right, it’s POSuggChg. BOReader works with BOName not viewName. In this case, there similar.
2- Don’t put any space in your field list. I’ve tried “PONum,POLine” and “PONum, POLine”. In the second example, I lost the POLine column in the dataset.
3- The fields you are requesting do not exist in the result dataset.

1 Like
  1. Thanks for the explanation.
  2. Thanks for the tip.
  3. How do I get the fields I want into the result dataset? The fields do not exist in the current view. So I used Tools/Data Tools to hang a view off of the POSuggView to get the fields I need. I used PONum to get the POAdapter and then tied the PODetail to that. I know it is working because I also added two fields on the Detail tab of the Change PO Suggestion screen and those fields populate.

I’m not sure what is the best approach here. I’m not really sure what info you are searching.

First, make sure the information needed is not in another field name such as POLineVenPartNum (that field is in your view).

I would consider a bpm on GetRows.PostProcessing. I would fetch in PODetail the desired info for each row in the GetRows dataset and put it in the UD fields (NumberXX or ShortCharXX are available in the dataset).

Hope it helps.