Greg On Dynamics Ax

Random thoughts about development using Dynamics AX and .Net

Handy editor script

leave a comment »

Editor scripts can come in really handy for repetitive tasks.

Being quite a stickler for code that is nice to read, I have written an extension that makes it easy to format blocks of variable assignment or declarations into nicely formatted columns.

Take the following code, for example:

static void Example(Args _args)
{
    IntrastatParameters intrastatParameters = IntrastatParameters::find();
    SalesTable salesTable;
    NumberSeq numberSeq;
    SalesLine salesLine;
    SalesFormLetter salesFormLetter;
    ;
    numberSeq = NumberSeq::newGetNumFromCode(SalesParameters::numRefSalesId().NumberSequence);

    salesTable.SalesId = numberSeq.num();
    salesTable.TransactionCode = intrastatParameters.DefaultSalePurchase;
    salesTable.Transport = intrastatParameters.TransportModeParm;
    salesTable.Port = intrastatParameters.PortParm;
    salesTable.CustAccount = "4015";

By selecting the blocks of declarations, then choosing Scripts -> addIns -> FormatToColumnLayout, will result in the following:

static void Example(Args _args)
{
    IntrastatParameters intrastatParameters = IntrastatParameters::find();
    SalesTable          salesTable;
    NumberSeq           numberSeq;
    SalesLine           salesLine;
    SalesFormLetter     salesFormLetter;
    ;
    numberSeq = NumberSeq::newGetNumFromCode(SalesParameters::numRefSalesId().NumberSequence);

    salesTable.SalesId         = numberSeq.num();
    salesTable.TransactionCode = intrastatParameters.DefaultSalePurchase;
    salesTable.Transport       = intrastatParameters.TransportModeParm;
    salesTable.Port            = intrastatParameters.PortParm;
    salesTable.CustAccount     = "4015";

You can find more detail, including the download here at axaptapedia.

Advertisements

Written by gregondax

January 24, 2009 at 7:12 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: