Rollback all the previous transaction without error in Business central


I have created a report to import items, item variant, sales prices, and purchase prices from XML file( using dl assembly) and in the end show statistical data like no. of new items created, no. of items updated, no. of items unmodified etc. into business central.

I want to implement preview feature in BC 15.

This feature goes through the same report and create items, item variant, sales prices, and purchase prices. But at the end everything has to rollback except statistic data.

Is there any way to rollback without creating error and at the end show the statistical data?

After lot of research I found that you can user Asserterror() todo the rollback but in BC, microsoft doesn’t not allowed to use in production code.

are there any alternative solution in BC?

Thanks in advance.

Perhaps a “silent error” can do it - an error-message without a message: »ERROR(’’);«

Thank you so much for your reply.

The ERROR(); methods stops the AL code and program completely.

I don’t want to break the program but just rollback at the end and do some calculation and show the statical data at the end.

The ERROR command is the correct approach. The tricky part is putting it in the right place. You need to collect and display your info before tripping the error. HINT: ERROR will not rollback temporary records.