One of the most important things every developer should handle is to clean up the environment when the environment (or a company) is copied. Especially if the environment is managed directly by a client and they can create new copies anytime. Similarly, for copied companies.
Today I would like to discuss a custom solution about Business Central, how to copy attachments from Warehouse Receipt to Posted Warehouse Receipt.
I was asked this question yesterday, it’s not very difficult, so in this post I want to share it briefly, if you encounter similar requirement, I hope it can give you some hints.
In the earlier version of Business Central, the only way to copy data between companies was either to copy the company or upload the data through Configuration Packages or Rapid Start.
Microsoft introduced Copy Data from Companies to copy data from specific tables in companies to your respective table in your company.
If you ever needed to copy temporary record variables, you probably already stumbled across ToRecord.Copy(FromRecord, true), with the second parameter true being used. But be careful: it works differently than you might think!
Imagine two temporary record variables, both pointing to the same base table: