Getting Data from PartPlant_UD In OrderDtl_BeforeFieldChange for Order Entry C#

(Blake Martin) #1

I will start this post that by saying I am a beginner when it comes to both C# and Epicor. Getting help on this question would help connect a lot of dots for me when it comes to both.

What is the best way to access data in custom code from, in this case, PartPlant_UD.Character04 from Sales Order Method OrderDtl_BeforeFieldChange?

Here is my code:

private static void OrderDtl_BeforeFieldChange(object sender, DataColumnChangeEventArgs args)
// ** Argument Properties and Uses **
// args.Row[“FieldName”]
// args.Column, args.ProposedValue, args.Row
// Add Event Handler Code

	switch (args.Column.ColumnName)
		case "PartNum":
			PartPlantSearchAdapter ppAdapt = new PartPlantSearchAdapter(oTrans);
			EpiDataView myEdv = (EpiDataView) oTrans.EpiDataViews["OrderDtl"];
			PartPlantSearchDataSet ppDataSet = new PartPlantSearchDataSet();
			ppDataSet = (PartPlantSearchDataSet)(ppAdapt.GetData(args.ProposedValue.ToString()));

                            //HOW TO GET CHARACTER04 FROM PartPlant_UD BASED ON PartNum????

Am I headed in the right direction? I have attempted to manipulate ppDataSet to get Character04 (code not shown), to no avail. My code compiles and I think I have the right assembly references. Should I cast it to a PartPlantSearchDataSet, or just use a normal DataSet? What methods/properties do I used to access the data if I used either of these? Should I be using a BAQ instead? So many questions, a nudge in the right direction would be huge. :slight_smile:

Thanks in advance.

Blake Martin

(Chris Conn) #2

If you do MessageBox.Show(ppDataSet.Tables[0].Rows[0][“PartNum”].ToString()); does it show you the proper partnum?

If so - ppDataSet.Tables[0].Rows[0][“Character04”].ToString();

(Chris Conn) #3

Another option might be to something like this: (note it uses the current plant)

var ppAdapt = new PartPlantSearchAdapter(oTrans);
string part = args.ProposedValue.ToString();
string plant = ((Ice.Core.Session)oTrans.Session).PlantID;
  var char4 = ppAdapt.PartPlantSearchData.PartPlant.Rows[0]["Character04"].ToString();

(Blake Martin) #4

The first suggestion yielded the same results I had been getting; namely nothing. No message box would come up. A little more testing may glean exactly what was going on in this scenario.

The second suggestion returned exactly what I wanted. I appreciate the prompt, and valid, response. Thank you, Chris!