BC Friday Tips #10 Use SetLoadFields to partially load data from a table
Happy Friday! Time for our weekly BCFridayTips for the msdyn365bc developers!
Use SetLoadFields to partially load data from a table.
Why?
✅ Improve Performance. Fetching only the necessary fields can significantly improve performance, particularly when dealing with table extensions.
However, remember that using it for write transactions could be counter-productive because logic on triggers and event subscribers can cause the record to be fully loaded.
It’s also recommended not to use it when executing multiple queries on the same table with varying field sets, like Setup Tables. In such cases, loading all fields and utilising cached data for subsequent queries is more efficient.
“However, remember that its usage should be limited to read transactions. Using it for write transactions would be counter-productive because the write transaction requires the record to be fully loaded.”
That’s not (always) correct, see https://x.com/PhDuck2/status/1530892365891833857 and https://x.com/PhDuck2/status/1530893275577581569.
Thanks, Natalie. You are right. I updated the post.