Collectible errors: Codeunit.Run Rollback

Hello Everyone,

I’m currently working on a validation task within Dynamics 365 Business Central, specifically focusing on validating customer address fields. The objective is to identify any missing fields and present them in a user-friendly interface for better user experience.

Initially, the validation process was straightforward, and I successfully implemented error collection to gather all missing field errors until the end of the validation process.

But then I stared wandering about what will happened if the Codeunit has transaction action like insert, modify or delete on the database…

I added a line of code to modify an address field and wanted to see if validation still works, but I can’t view error messages without committing changes.

Unfortunately, committing also saves the changes, which is not the behavior I desire for this validation process.

Is there an alternative method to execute the Codeunit.Run within a function that collects errors and rolls back transactions afterward?
My goal is to display the list of errors encountered during the validation process without committing any changes made during the transaction.

Appreciate any insights or suggestions.
Thank you.