Detect destructive Modify() on non-initialized record #1213
ernestasjuska
started this conversation in
New Rule
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi,
Juniors can make silly mistakes like this (in reality code could be much more complex):
The problem with this code is that General Ledger Setup record exists in pretty much every BC company. Meaning, that this code will execute just fine without any complaints and will clear every field in the record.
Consider adding rule that detects when Modify is used without initializing record first.
Keep in mind that code like this is also possible - it is very difficult to check that GetOrCreate actually initialized the record, so I would prefer some extra check (prefer error over silent destruction of data).
Thanks.
All reactions