View elements of OrderDtl from OrderHed

Hi all! I need to do a customization that take a Order (in Order Entry so OrderHed), it looks every PartNum in the line (so OrderDtl.PartNum) and for every one it do a thing based on the OrderDate of the order. I started directly with the custom code:
Tried with the OrderHed_AfterFieldChange for the “OrderHed.OrderDate”. With this I now have the date of the order, but now I am unable to do the loop for every OrderDtl.PartNum of the order.
Can someone help me please? Thanks!

How and when do you want this to happen?

  • Line created/updated - Run (for this line) when the line is updated
  • Button click - Process all existing lines
  • Upon loading an existing order in Order Entry
  • Rerun on all lines if header’s order date is changed?

Do the updates need to appear in the Order Entry Screen?

Hi! I would need this for points 1,3 and 4. (always so…)
Every PartNum of line will transform an object (string) that will be displayed in a custom entry that I already added on the view and already modified with the 'args.Row"

Typically the OrderDate is set prior to any lines (OrderDtl’s) being added to the order. So you’d want your process to run after the PartNum changes. Like how the Description is automatically updated after changing PartNum.

If the OrderDate changes, then you need to loop through all the OrderDtl’s and recalc that UD field.

Customization’s aren’t my specialty, so I don’t want to suggest which events to use - as I could very easily point you in the wrong direction.

assuming you are using the EpiDataViews on the form. You probably could have something loosely like this:

//using System.Linq;
foreach(var h in edvOrderHead.dataView)
    foreach(var d in edvOrderDtl.dataView.Table.AsEnumerable().Where(d => d["OrderNum"].ToString() == h["OrderNum"].ToString()))
  { //all details where ordernum is same as the header
        if((DateTime)h["OrderDate"] == DateTime.Today) 

How can use OrderHed and OrderDtl in the same function?
It always tells me that one of the two is not found by the system.
In which function do I need to do a similar code?

Assuming your form has these views. You can use Tools>Object Explorer>Data to see the views.

Then you can get a reference to any view you need:
var myView = oTrans.Factory(“ViewNameHere”);

Nice, thanks for the help.
I’ll kepp this thread updated with the results!