Designing reusable code
Code modules in NAV are called codeunits. A codeunit does not have any user interface; the only purpose of a codeunit object is to store application code that can be called from other objects.
How to do it...
Now we will create a codeunit that will store functions common for objects in the current chapter, and move duplicated code from different objects into the codeunit.
Create a new codeunit in object designer. Save it as codeunit 50010 Item Certificate Mgt.
Declare a global function
GetCertificateExpirationDate
.Select the function in C/AL Globals list and open its properties. By default, property Local is set to Yes. Change it to No to make the function accessible from other objects.
Open function parameters in C/AL Locals and declare one parameter:
Name
Type
Length
CertificateNo
Code
20
Still in C/AL Locals, add a local variable to the function:
Name
DataType
Subtype
ItemCertificateAction
Record
Item Certificate Action
Change the function...