A Codeunit as a method
Wouldn't it be nice if we could look at the Customer table, and see what we can do with it?
To do this, we need to implement a new function on the Customer table. Let's call it FormatAddress
. We'll give it the Addr
text variable as a parameter. Codeunit 365 can be a local variable in the function, as in the next screenshot:
When we do this, we can use the FormatAddress
function each time we have access to a customer record without declaring a Codeunit, or even knowing that it exists. If we apply logical naming, and group similar functions together, other developers will find it easier to know about these functions. The suggested naming should always contain a verb and noun.
Now that this function exists, we can simply refer to it from our report without declaring the Codeunit. We only need the Text array.
This way of working with functions as a member of the process owner is normal in object-oriented programming, where we will use classes. Using...