Answer
Check what parameters the auto-generated custom-field function actually accepts — if the field is defined using only a header-level key (like just Order No) while the screen it's placed on is actually at a more granular level (like Customer Order Line, which is uniquely identified by Order No + Line No + Rel No + Line Item No), the generated function only ever receives the header-level key, so it returns the same result for every line sharing that same header value, regardless of which specific line is actually being displayed. The fix is to define the custom field's arguments to include the full set of key columns matching the actual screen/record level it's placed on, not just whichever single key column happens to be convenient.