Set table record in Standard Data Directive

I need to dynamically build text based on the PartNum entered on an OrderDtl, and store it in a the custom field ProdLabel_c in the OrderDtl table. The derived text needs info from tables OrderHed & Customer too.

I originally used an In-Trans Data Directive, as it has the “Set Field” block in the BPM workflow. But the function to build the ProdLabel_c text is too complex to put in the “expression” of the Set Field block. So I decided to use an Execute Custom Code block to set variable, then use the variable in the Set Field block’s expression.

The problem is when the custom code encounters an error, the original transaction is halted. The errors aren’t syntax related, but rather run-time errors. Errors like an array out of range, or even just using string.Substring(x,y) if x or y end up out of range. I’ve added lots of checks before accessing arrays, or any calls that I think might result in an error (checking array sizes, string lengths, etc…), but I can’t afford to have the original transaction halted on an error.

I’m okay with the ProdLabel_c not getting updated on an error, but the original transaction must be allowed to proceed.

In a nut shell, I’m not sure how to set the OrderDtl.ProdLabel_c field in a Standard DD.

If a BPM or customization would be better, I’m open to either of those too.

Perhaps in your custom code you wrap your potentially failing code in a try…catch block. This should allow execution to continue.

//scary code goes here
//any special things you want to happen if above code fails