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?

  • RT @DestroyingCIips: What snake venom does to your blood 55 minutes ago
  • ஆரிய வருகை, அறிவியல் உண்மை 10 hours ago
  • RT @ThanthiTV: மாநில பாடத்திட்டத்தில் படித்து #NEET தேர்வில் வெற்றி பெற்ற மாணவர்களுக்கு மருத்துவ படிப்புகளில் 85% இடஒதுக்கீடு வரவேற்கத்தக்க… 11 hours ago
  • @Sagacious_Chap Avan evalavo nalla vishayam solvan, adhellam share pannadha. Idhalayum onnum thappu ilaye, ipa ellarum apadi dhana irukom 18 hours ago
  • RT @DirAmeer: பண்டைய தமிழனின் அடையாளமான கீழடி#கண்டெடுக்கப்பட்ட பொருட்களை பாதுகாக்க அருங்காட்சியகம் அமைக்க உத்தரவிட்ட உயர்நீதிமன்றத்திற்கு… 1 day ago
  • RT @bbctamil: கீழடியில் அருங்காட்சியகம் அமைக்க மதுரை உயர்நீதிமன்றம் உத்தரவு 1 day ago
  • விளங்கி விடும் நாடு… 1 day ago
  • @Sagacious_Chap பாறை? 1 day ago
  • RT @NaamTamilarOrg: ஆடு மாடு வளர்த்தல், விவசாயம் அரசுப்பணி என்று ஏன் சொல்கிறோம் ; பிளாஸ்டிக் அரிசியைத் தின்று என் மக்கள் செத்துவிடக்கூடாது… 1 day ago
  • RT @AnandaVikatan: கதிராமங்கலத்தில் மாடு மேய்ப்பவர்களைக்கூட பின் தொடரும் போலீஸ்! ஏன்? #Kathiramangalam… 1 day ago


Join 13 other followers