Common Mistakes I See
Mistake #1
Putting import-specific logic inside `modifiedField()`.
Works in UAT from UI.
Fails in production import.
Classic.
Mistake #2
Adding everything into table `insert()`.
Now every integration, batch job, X++ process and custom service executes the same logic.
Unexpected side effects incoming.
Mistake #3
Forgetting datasource-specific processing.
Remember: _dataSourceCtx.name() exists for a reason.
Always check which datasource you're handling.
Mistake #4: The Dangerous Copy-Paste Trap 😄
We've all done it.
You need similar logic in another Data Entity.
So you copy code from one entity, paste it into another, change a few things, run a quick test, and everything works.
For example: case dataEntityDataSourceStr(SalesOrderLineV2Entity, SalesLine):
You copied this from another entity extension but forgot to change: SalesOrderLineV2Entity to your current entity.
Surprisingly, the code may still work.
Why?
Because `dataEntityDataSourceStr()` ultimately resolves to the datasource name, and if both entities happen to use a datasource with the same name (`SalesLine`), your condition may still match.
So everybody is happy.
Code review passes.
Testing passes.
Production runs fine.
Then six months later someone modifies the datasource name in the original entity.
Suddenly your completely unrelated entity stops executing its logic.
Now comes the fun part: "Nothing changed in my entity."
Technically true.
But your code was accidentally depending on metadata from another entity.
Reality Check
Junior Developer - "modifiedField works. Ship it."
Senior Developer - "Will this also work through DMF, OData and integrations?"
Architect - "Which layer actually owns this business rule?"
The difference isn't coding.
The difference is thinking about all entry points.
Final Thoughts
✔ Data Entities don't behave like forms
✔ modifiedField() is usually bypassed during imports
✔ insertEntityDataSource() and updateEntityDataSource() execute per datasource
✔ They provide access to datasource buffers
✔ They are perfect for integration-specific logic
✔ They are extremely useful when working with unmapped entity fields
✔ Not every business rule belongs in table insert/update
"In D365 F&O, the question isn't 'Can I write the code here?' The real question is 'Should this logic live here?'"