Friday, October 31, 2008

Setting up E-mail parameters on the AX 2009 VPC July 2008 image

In order to send e-mail within this image, you need to setup SMTP parameters in AX:

Go to Administration / Setup / E-mail parameters:

Default in the form you'll find the follwing settings:
SMTP port number: 25
Attachment size limit (MB): 10

Enter the following new values:
Outgoing mail server:
Local computer name: dynamicsvm

And here is a small job to see if mail can be sent:

static void testMail(Args args)
SysMailer   sysMailer = new SysMailer();

sysMailer.quickSend("", "", "Subject", "Body");

Please note that the test mail might end up in your Outlook junk-mail folder.

Thursday, October 23, 2008

Finding unused labels

Here is a small job for finding labels, from a particular label file, that are not used in the application. You need an updated cross reference to use the job.
static void findUnXedLabels(SysOperationProgress _progress = null)
Label label = new Label('da'); // The language to use for finding the labels
str 250 labelId = label.searchFirst('');
Map mapLabels = new Map(types::String, types::String);
MapEnumerator mapEnumerator;

setPrefix("Finding UnX'ed labels");

while (labelId)
if (label.moduleId(labelId) == "XYZ") // The particular label file
if ((select xRefNames
index hint Name
where xRefNames.Kind == xRefKind::Label &&
xRefNames.Name == labelId &&
xRefNames.TypeName == '').RecId == 0)
mapLabels.insert(labelId, label.extractString(labelId));
labelId = label.searchNext();

// The maps is used to sort the lables
mapEnumerator = mapLabels.getEnumerator();

while (mapEnumerator.moveNext())
info (strFmt("%1 %2", mapEnumerator.currentKey(), mapEnumerator.currentValue()));

In standard AX you can run this check for all labelfiles and save the result to a file, by using the \Classes\SysApplCheck\findUnXedLabels method.

Monday, October 20, 2008

Saving the reference to a unique record as a string

Sometimes you have have to store a unique reference to record as a string, for example if you want to include this reference in an XML file.

Merely converting the RecId to a string is not always a good idea. The best choice for identifying the record may be another unique key of the table, especially if the table doesn't have a RecId index.

On the Global class there is a method to analyze the unique keys of a table and give you the unique key as a string. This is the record2Dynakey method.

The key is encoded in the string like this:

Later when you want to convert the string, representing the key, to an actual record, just call the dynaKey2Record method.

You should not use this technique for long term storage of keys, since renaming primary keys or changing the datamodel might break the ability to restore the string into the right record or restoring it in the most sufficient way.

Friday, October 10, 2008

Manage Enterprise Portal deployments

In a multi server setup of EP 2009, you could be tempted to install the .NET Business Connector as the only AX part on the IIS.

It turns out that you must also install a regular client, because the "Manage deployments" form only will run from the box where EP is deployed...