I recently got a question about TransferFields and if if skip fields with editable false, which it should not, imho.

When I looked at the documentation about Transferfields: Record.TransferFields(var Record [, Boolean]) Method – Business Central | Microsoft Learn I noticed this remark:

Fields are assigned, such as DestinationRecord.Field := SourceRecord.Field, which won’t call the OnValidate trigger on the destination field. To assist with validation when using the TransferFields method, the TypeHelper codeunit contains a TransferFieldsWithValidate method.

So in the TypeHelper codeunit there’s a TransferFieldsWithValidate:

It’s used a bit in the base app:

(Code analyzed using: Statical Prism for AL)

 

Update:

Some very interesting feedback from Arend-Jan Kauffmann:

The typical use case is transferring data from a buffer table without code in the triggers to the target table. For example a buffer table filled by an API call.


Discover more from think about IT

Subscribe to get the latest posts sent to your email.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post Navigation