Get

I Have a Method Directive to execute Custom Code each time i change or Add Item Number in OrderEntry. The BPM is in Pre-Process mode.

With This code the value of item[“PartNum”] is Always the current value and not the new Value.

What i’m doing wrong?

Erp.Tables.Part Part;
foreach(var item in ds.OrderDtl.Where(row => row.Added()||row.Updated()))
{
if(item[“PartNum”]!=null)
{

Which method are you using? MasterUpdate?

The Methode i use is ChangePartNumMaster

You might not be doing anything wrong, but maybe the new part number isn’t available in preprocessing?

I’m with Doug, what method are you using?

Isn’t there one that’s like “onchangepartnum” or is that order dtl? :sweat_smile:

You are loooking up the number in the database on a “pre” processing directive. It hasn’t yet been committed so it won’t be there

I suspect you should be looking in your current dataset instead but….
Let’s rewind a bit what are you trying to do?

1 Like

I want to validate in order entry if the part entered exists in Parts Database
see the code that i found.

Erp.Tables.Part Part;
foreach(var item in ds.OrderDtl.Where(row => row.Added()||row.Updated()))
{
if(item["PartNum"]!=null)
{
          
Part = (from Part_Row in Db.Part 
          where string.Compare(Part_Row.Company,item.Company,true) == 0 &&
Part_Row.PartNum == item.PartNum select Part_Row ).FirstOrDefault();          

if(Part==null)
{
throw new BLException("Part "+ item["PartNum"].ToString()+ " is not created in System, Please create "+ item["PartNum"].ToString()+ " in part master and proceed. ");
}
}
}

I Tried to do this in pre-processing with this method

ServiceName : SalesOrder
MethodeName : ChangePartNumMaster

@jplafleur You can do this in Update without any coding.

SalesOrder.Update
image
Query

Jean, you,

want to validate in order entry if the part entered exists in Parts Database

And then what?

Yo Jean @jplafleur , try to use the partNum variable available to you.

You can reference it in your code block by typing partNum.

Mileage may vary.

So

         where string.Compare(Part_Row.Company,Session.CompanyID) == 0 &&
Part_Row.PartNum == partNum select Part_Row ).FirstOrDefault();          

if(Part==null)
{
throw new BLException("Part "+ partNum.ToString()+ " is not created in System, Please create "+ partNum.ToString()+ " in part master and proceed. ");
}
}

Not sure if it will work 100% I am just trying to spur some ideas.