Building a lookup for selecting a file
In Dynamics AX, file reading or saving is a very common operation. Most of the non-automated file reading or writing operations prompts the user to specify the file name.
This recipe will demonstrate how the user could be presented with the file browse dialog, in order to choose a file in a convenient way. As an example, we will create a new control called Terms & conditions in the Form setup form in the Procurement and sourcing module, which allows storing of a path to the text document.
How to do it...
1. In the AOT, open the VendFormLetterParameters table and create a new field with the following properties:
Property
Value
Type
String
Name
TermsAndConditions
Label
Terms & conditions
ExtendedDataType
FilenameOpen
2. Then add the field to the bottom of the table's PurchaseOrder field group.
3. Next, open the PurchFormLetterParameters form, and create the following four methods:
public str fileNameLookupTitle() { return...