Vasanth Arivali's Blog

Hi Guys,

Here I have posted a sample job to fetch the Dimension values based on the LedgerDimension in Ax 2012. This will give the clear picture how the LedgerDimenion(Combination of MainAccount-Dim1-Dim2-Dim3) is mapped with each Dimension Values

/// This will get the Dimension based on your AccountStructure of the Current Company and Posting Profile Setup.

static void getDimensionValueFromLedgerDimension(Args _args)


DimensionAttribute                          dimensionAttributeTable;

DimensionAttributeValueGroupStatus          dimAttrValueGroupStatusTable;

DimensionAttributeValueGroupCombination     dimAttrValueGroupComboTable;

DimensionAttributeValueGroup                dimAttrValueGroupTable;

DimensionAttributeLevelValue                dimAttrLevelValueTable;

DimensionAttributeValue                     dimAttrValueTable;

DimensionAttrValueCOAOverride               dimAttrValueCOAOverrideTable;

DimensionAttrValueLedgerOverride            dimAttrValueLedgerOverrideTable;

DimensionFinancialTag                       dimensionFinancialTagTable;

InventPosting                               inventPostingTable;

DimensionValue                              Dimension1, Dimension2, Dimension3;

MainAccountNum                              LedgerAccount;

RecId                                       LedgerRecId, dimCombinationId;

dimCombinationId    = 5637144728; // for example here i gave a valid ledgerdimension

// find MainAccountId from LedgerDimension

LedgerAccount       = MainAccount::findByLedgerDimension(dimCombinationId).MainAccountId;

LedgerRecId         = Ledger::findLedgerRecIdByLegalEntity(CompanyInfo::findDataArea(curext()).RecId);

Dimension1 = “”;

Dimension2 = “”;

Dimension3 = “”;

while select Ordinal from dimAttrValueGroupComboTable order by Ordinal

where dimAttrValueGroupComboTable.DimensionAttributeValueCombination == dimCombinationId

join dimAttrValueGroupTable

where dimAttrValueGroupTable.RecId == dimAttrValueGroupComboTable.DimensionAttributeValueGroup

outer join dimAttrValueGroupStatusTable

where dimAttrValueGroupStatusTable.DimensionAttributeValueGroup == dimAttrValueGroupTable.RecId

join dimAttrLevelValueTable

where dimAttrLevelValueTable.DimensionAttributeValueGroup == dimAttrValueGroupTable.RecId

join pessimisticLock IsSuspended, IsTotal, ActiveFrom, ActiveTo, DimensionAttribute, RecId, EntityInstance from dimAttrValueTable

where dimAttrValueTable.RecId == dimAttrLevelValueTable.DimensionAttributeValue

outer join pessimisticLock IsSuspended, ActiveFrom, ActiveTo, RecId from dimAttrValueCOAOverrideTable

where dimAttrValueCOAOverrideTable.DimensionAttributeValue == dimAttrValueTable.RecId && dimAttrValueCOAOverrideTable.ChartOfAccounts == LedgerChartOfAccounts::current()

outer join pessimisticLock IsSuspended, ActiveFrom, ActiveTo, RecId from dimAttrValueLedgerOverrideTable

where dimAttrValueLedgerOverrideTable.DimensionAttributeValue == dimAttrValueTable.RecId && dimAttrValueLedgerOverrideTable.Ledger == LedgerRecId


dimensionFinancialTagTable = null;

select * from dimensionFinancialTagTable

where dimensionFinancialTagTable.RecId == dimAttrValueTable.EntityInstance

join dimensionAttributeTable

where dimensionAttributeTable.RecId == dimAttrValueTable.DimensionAttribute;

if (dimensionAttributeTable.Name == ‘Department’)


Dimension1 = dimensionFinancialTagTable.Value;


if (dimensionAttributeTable.Name == ‘CostCenter’)


Dimension2 = dimensionFinancialTagTable.Value;


if (dimensionAttributeTable.Name == ‘Purpose’)


Dimension3 = dimensionFinancialTagTable.Value;



info(strFmt(“%1     %2      %3”,Dimension1,Dimension2,Dimension3));




Here I have written a sample code to execute a simple secenario with “Common” Table in Ax 2012

static void Job_UsingCommonTable(Args _args)





InventPosting                    inventPosting;

container                           conCompanies = [‘CEE’, ‘CUE’, ‘DMO’];

InventItemGroupForm    inventItemGroupForm;

container                           tableList = [tableStr(Inventposting), tableStr(InventItemGroupForm)];

TableName                        name;

int                                       loop;

void updateDimension(Common common)


DimensionAttributeValueCombination  dimensionAttributeValueCombination;


while select crossCompany:conCompanies common


select forUpdate LedgerDimensionType, RecId from dimensionAttributeValueCombination


dimensionAttributeValueCombination.RecId == common.(fieldName2id(common.TableId,  #ledgerDimension));



dimensionAttributeValueCombination.LedgerDimensionType =  LedgerDimensionType::Account;





info(strFmt(‘DimensionAttributeValueCombination is update for Table: %1’, tableId2name(common.TableId)));


for (loop = 1; loop <= conLen(tableList); loop++)


name = conPeek(tableList, loop);



case #inventPosting :



case #inventItemGroupForm :







Thanks & Regards,

Vasanth Arivali

Hi All,

We all know about “Go To Main Table” Option in our Axapta Forms and Tables. Here I wrote one sample for how to get that functionality in our forms or table. This is done by three ways:

1) By EDT Relations

2) By using JumpRef method

3) By using FormRef property in Table

EDT Relations:

If you use an EDT in tables which have relation with some other table fileds, that time you can able to navigate the main table or main form.

FormRef Property:

Select the Table and go to properties and select the required form in the FormRef property.

JumpRef method:

If you are not having that option, simply write a override the JumpRef method in a field of DataSource or in a Form Control. Here i show you a sample jumpRef method code:

public void jumpRef()
Args            args;
MenuFunction    menuFunction;

args = new Args();
menuFunction = new MenuFunction(menuitemDisplayStr(“FormName”), MenuItemType::Display);
args = new Args(menuFunction.object());
args.record(“RecordName”); // to be a datasource which added in the current form;

In the form init() which we called here, we have to check the condition whether the form is called by any dataset or not.

Thanks & Regards

Vasanth Arivali

Hi Guys,

Here i posted a small job , to explain how we use regular expressin in Axapta. Try it.

static void RegularExpression_Test()


int nameLength,myStringLength;

str myname = “Vasanth”;

str myString = “1234”;

str formatString , formatString1;

System.Text.RegularExpressions.Regex regEx;

System.Text.RegularExpressions.Regex regEx1;

System.Text.RegularExpressions.Match regMatch;

InteropPermission permission = new InteropPermission(InteropKind::ClrInterop);

boolean retVal, retVal1;


nameLength = strLen(myname);

myStringLength = strLen(myString);

formatString   = strfmt(@”^[0-9]{%1}”, myStringLength);

formatString1   = strfmt(@”^[a-zA-Z ]{%1}”, nameLength);


//BP Deviation documented

regEx = new System.Text.RegularExpression.Regex(formatString);

regEx1 = new System.Text.RegularExpression.Regex(formatString1);

regMatch = regEx.Match(myString);

retVal = regMatch.get_Success();

print retVal; // Returns True;

regMatch = regEx1.Match(myname);

retVal1 = regMatch.get_Success();

print retVal1 // Returns True;


Thanks & Regards,

Vasanth Arivali

Hi All,


Here i written the code to use the Aggregate functions and Joins in Dynamic Query in spite of using normal Select statement in Ax 2009


Normal Select Statement:


while select sum(qty) from inventTrans where inventTrans.ItemId ==

“OL-2500” join inventDimgroup by inventBatchId where

inventDim.InventDimId == inventTrans.InventDimId


// Our Code Here



Dynamic Query:


static void Vasanth_Query_Eg1(Args _args)


Query                   query;

QueryBuildDataSource    queryBuildDataSource;

QueryBuildRange         queryBuildRange;

QueryRun                queryRun;

Qty                     total;

InventTrans             inventTrans;


query = new Query();    queryBuildDataSource    = query.addDataSource(tableNum(InventTrans));




queryBuildRange         = queryBuildDataSource.addRange(fieldNum(InventTrans,ItemId));

queryBuildDataSource    = queryBuildDataSource.addDataSource(tableNum(InventDim));




queryRun = new QueryRun(query);

if (queryRun.prompt())


while (


inventTrans = queryRun.get(tableNum(InventTrans));

total = inventTrans.Qty;



info(strFmt(“Quantity: %1”, total));


Here i posted the code to use the AOT Query Object in our X++ code.


1) Create a AOT Query Object as your requirement.

2) Create a Job and paste the below code to check the Query Object.

static void ExecuteAOTQuery(Args _args)


QueryRun queryRun;

Counter totalRecords;


queryRun = new QueryRun(queryStr(CreatedAOTQueryName));

if (queryRun.prompt())


while (





info(strFmt(“Total Records : %1”, totalRecords));


Hi All,

Here I create Lookups using X++ Code(without Ax Table or EDT relation). For that i override a String(Text) Control’ s lookup method.

public void lookup()


// Added by Vasanth Arivali

// Declaration
Query   LookupQuery    =   new Query();

QueryBuildDataSource     LookupQueryBuildDataSource;

QueryBuildRange                  LookupQueryBuildRange;
SysTableLookup CustomSysTableLookup =       SysTableLookup::newParameters(tableNum(InventTable), this);


// Add fields that you want in Lookups

CustomSysTableLookup.addLookupField(fieldNum(InventTable, ItemId));






// Add DataSource, Range and Value

LookupQueryBuildDataSource =





// Execute the Query


// Added by Vasanth Arivali



What’s happening?

Error: Twitter did not respond. Please wait a few minutes and refresh this page.


Join 12 other followers