Data Directive, BPM or customization?

I need to build some text and store it in a UD field in the OrderDtl table when a new order line is created or the PartNum changes. The text to store in OrderDtl.ProdLabel_c is based on info from the OrderDtl, OrderHed and Customer tables.

What’s the “best” method? DD, BPM, or customization? Pros and cons of each method?

I currently have an In-Tran DD for the OrderDtl that is does what I want, but I fear it’s not efficient.
Won’t this be called every time the OrderDtl table is touched? Even though I have conditions set for when the code should execute, it seems like so many things touch the OrderDtl line (like Shipping, and invoicing), that 99% of the time the DD is triggered, it will be for no reason. Plus the conditions are kind of elaborate, so those tests must be made every single time.

the conditions are :slight_smile:

image

The 1st is to see if the ProdLabel text hasn’t already been set.
The 2nd condition is a query to see if the PartNum matches any one of about 4 or 5 patterns
The 3rd condition is just to keep it from triggering by anyone else while I develop it

if the above conditions are met, and Exec Custom Code block executes. That sets two variables, ProdDesc and LabaleCnt. Those two variables are then used in Set Field blocks to set ttOrderDtl.ProdLabel_c and ttOrderDtl.ProdLabelCnt_c.

The reason I store this in a field as opposed to generating it during a report rendering, is because the user needs to be able to edit the text before printing.

Are there any pitfalls to what I’m doing? BPM or Customization be better?

I am not the guru of efficiency but my thoughts are that if you need to ensure you update your data on EVERY change of the orderDtl table (new line, change pn) - I would definitely keep it in a BPM. I do think that maybe you would be better suited to place it in a METHOD directive instead of a DATA directive. A data directive will fire for any change by any source which could have you getting called unnecessarily. Probably the Update() method of the OrderDtl table would be nice.