Part Parent

Yes. I’ll use the sql to write some linq. Grab the mtls. Get by ID each part. Add/update site. Save.

So using SQL directly in your customization is a HUGE no no in the Epicor world.
The customization should use business objects and BAQ’s to put and pull data
You can accomplish the same in your customization by running a baq.

3 Likes

Using linq in a customization is okay though right?

You can use LINQ in a customization, but a customization doesn’t have access to the data-model so I’m not certain how that would help.

Here’s what i’m working with so far…


				//grab the plant we're passing down to ECO mtls
				string revisionPlant = edvECORev.dataView[edvECORev.Row]["Plant"].ToString();  //current plant we're in
				string revisionPartNum = edvECORev.dataView[edvECORev.Row]["RevisionNum"].ToString();  //Name of the revision
				string revisionCompany = edvECORev.dataView[edvECORev.Row]["Company"].ToString();  //Name of the company we're in

				//Grab the ECO Materials related to the Revision (skip if there is none)
				if (edvECOMtl.dataView.Count == 0) {
					return;
				}

				var materialPartList = (from revision in PartRev

					join material in PartMtl on revision.RevisionNum equals material.RevisionNum 
					join part in Part on material.MtlPartNum equals part.PartNum
					join partplant in PartPlants on material.MtlPartNum equals partplant.PartNum
					where revisionPartNum == revision.RevisionNum && revisionCompany  == revision.Company
					&& revisionCompany  == material.Company && revisionCompany  == part.Company
					&& revisionCompany  == partplant.Company
					
					select new {
					Company = part.Company,
					PartNum = part.PartNum,
					Plant = partplant.Plant,
					}).ToList()

				foreach(var mtl in materialPartList){
					
				}

I’m almost certain that I could’ve looped over edvECOMtl here too, but went with the linq solution thus far

Where is PartRev, Part and PartPlants defined? (In your customization)

1 Like

How can I use Db.PartMtl.With(LockHint.NoLock)

But this is a customization Db is not in the customization… is this not a customization?

You can’t access DB context in a customization you have to use a BAQ.

2 Likes

Decided to loop over a mtl dataview to grab mtlnums that I’ll need to run my getById and update for sites

why poop

Workable but not a desired, scalable, or futureproof approach. You’ll some day come back to it and wonder what was i thinking but that’s ok we all do lol

2 Likes

Just teasing ya :rofl:

So, GetByID is a really heavy solution GetBYID get s a LOT of information, I recommend you try either BOReader or call a BAQ to pull a few fields out of a table.

1 Like

That’s kind of why I’m leaving a trail of what seems like easy things. Thanks guys. Got the adapter set up. Should be relatively easy from here.

1 Like

You really put up with a lot of my dumb questions. Thanks for your perseverance

There are no dumb questions :slight_smile:

3 Likes
2 Likes

Trust me. Others are learning from this thread who didn’t have the willingness to ask. So thanks for being here.

1 Like

Okay. So I can’t use an adapter with methods to complete my objective? Looking at methods on PartAdapter. Not seeing much of worth. I guess my next stop is tracing to see what is called when a part is loaded.

Tracing should always be your first step.
Step back
Do the whole process manaully with trace on
Then follow the trace with code
Recipe for success

Poke around the forum I wrote a utility to help you parse the trace file too

3 Likes