Sum of EstScrap

Hi all,

Still getting accustomed to Epicor, and was wondering what the Best Practice for this customization would be.

Running total of Scrap so that the Ecoopr.EstScrap value is equal to the scrap projected in the operation and all subsequent Operations.

The goal is something like below:
image

I have the custom column added to the ECOOpr Table and I was able to get a BAQ to do the calculation. The problem I am running into now is running a function/event/BAQ to overwrite ECOOpr.EstScrap with my calculated value. Ideally when a user changes the custom Column ScrapbyOp Estscrap would calculate the new value for all operations for the part. Although if that would be too complicated, an event to update the fields after a save to the database would work too.

Thanks!

Doable, with some code.

Triggering the action seems straightforward, on field change of ScrapByOp, you can do that easily in either method(preferred) or data directive.

I’d put all the logic in a function.

The logic is mainly just BO code to properly update the records (since we never usually dont want to write directly to the fields).

Either you are going to have to use the Update method to update, passing in the entire (updated) dataset, or you could get away with using UpdateExt and just passing in the key fields and fields you want to change.

I know it’s somewhat of generic response but there is lot involved to the “little” stuff I am unsure of your level of expertise. If you have any specific questions let me know.

2 Likes

Chris,

I appreciate the reply. This is my first foray into this level of work inside Epicor.

The logic that I am fighting is the summation of ScrapByOp. The code I put together either uses a where clause select clause and the Expression editor says that is not supported. What is the best way to set that value?

Ignoring the technicals of the update itself and just focusing on logic, I think I would approach it generally like this:

  1. The logic is inside of function
  2. The function library has refs to tables storing your fields
  3. Pull data directly from tables using linq, maybe var myoprecs = Db.ECOOpr.Where( w=>w.Company == mycomp && w.PartNum == mypart && w.RevisionNum == myrev && w.OprSeq == targetoper)
  4. Once you have that data in IEnumerable filtered proper, you can do var mysum = myoprecs.Sum(s => s.EstScrap);
  5. Push that data where needed…which if the field you are updating is UD field, feel free to mark the ref table writable and push you values in direct as there is no logic to worry about (never do this for a system field)