Hope this might be helpful:
The "An error occurred and the transaction is stopped" when if Codeunit.Run() then is used in Business Central Cloud (unlike older On-Premise) means unhandled errors inside the codeunit immediately stop the entire transaction, preventing the Run() method from returning FALSE.
TryFunction is the correct way to handle and roll back transactions on error in modern BC. If your insert/modify isn't rolling back, it implies those operations are likely outside the TryFunction's scope or the error occurs elsewhere. You need to ensure the entire transactional unit of work is within the TryFunction to achieve rollback.
✅ Mark this answer as verified if it helps you.