Another useful way to use Code Coverage, is when something is happening in a process, but you just can’t figure out where exactly it happens. This happened to me the other day, in a client database with lots of customizations, made by a previous Solution Center and poorly documented, so it was hard to figure out exactly what they had done or why. So I decided to use Code Coverage.
The scenario used for this example, is just to show the different steps. It’s not the actual scenario described above. In this scenario, when Invoicing a Sales Order, Commission Ledger Entries get INSERTed, and I’m using Code Coverage to show you how you could go about finding out in what object that is done.
So I start up Code Coverage**, hit ‘Start’, Invoice my Sales Order, and hit ‘Stop’, and this is what the form looks like:
<span”>I then click the ‘Code’ button, remove the filters so I can see the code for all objects, and then set this filter: @*INSERT*
After locating where the Commission Ledger Entry actually gets INSERTed, I do CTRL+F8 to zoom into that line which tells me the Commission Ledger Entry gets INSERTed somewhere in Codeunit 50003:
When I then CLEAR all the filters, I see that the function in Codeunit 50003 that is used to INSERT the Commission Ledger Entries is called ‘CreateCommissionLedgerEntry’:
SCORE: So instead of spending a lot of time debugging, or searching through objects, I was able to locate what I was looking for in a matter of a few minutes.
*Part 1 of ‘Code Coverage’ was explaining how to use Code Coverage with the Client Monitor
**To read more on how to use Code Coverage, refer to my previous blog post.