I am working on setting up email templates in AX 2009 which would be sent out automatically to our customers when certain documents are posted. I have a framework in place that allows me to tie a specific posted document to a specific email template.
Currently, in order to have the information in the email dynamically populated, I am using a mapping object that holds key/value pairs, where the key relates to a specific variable in the template itself (see the sample in the question Dynamics Ax 2009, Email Templates). However, since I can very easily see the information that needs to be available changing significantly, I want to be able to change this mapping without having to change the actual code in the class.
My thought is to have a simple table, which contains two string fields - one would be the key in the mapping and the other would be the string representation of where the information is found, ie "salesTable.SalesId"
.
Is it possible to evaluate the value string expression so it would automatically pull "SO-XXXXXXXX"? In this case, we can assume that the salesTable buffer already exists at the point of evaluation. This would be similar to the Javascript eval()
command. It should also (ideally) evaluate more complex expressions, such as "CustTable::find(salesTable.InvoiceAccount).CustGroup"
, but at this point that may be too much to ask for.
The only other alternative I can see would be creating a giant mapping object that would contain all possible mappings and use that throughout the framework, but that still runs the risk of not having all the information that may be needed in a template, so would require additional code changes to get the missing information in.