Greg On Dynamics Ax

Random thoughts about development using Dynamics AX and .Net

Archive for the ‘Programming’ Category

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.

Written by gregondax

January 24, 2009 at 7:12 pm