Ax 2012: How to add TWO links between two datasources in X++ Query

In my Customization I need to get the From warehouse and To warehouse transaction from the Inventory Transfer Journal.

for this i need to relate  InventJournalTrans and InventTransOrigin tables with InventTransId and ToInventTransId, But here InventTransId is a direct relation, but if i use this relation then i can get only the From warehouse information. The linking is like the below


but i can’t make two relations like


so i code like Range setting in X++ query.


static void GetFromAndToWarehouse(Args _args)
InventJournalTable inventJournalTable;
InventJournalTrans inventJournalTrans;
InventTransOrigin inventTransOrigin;
InventTrans inventTrans;
InventDim inventDim;

Query query;
QueryBuildDataSource qbds,qbds1,qbds2;
QueryBuildRange qbr,qbr1;
QueryRun queryRun;

query=new Query();

qbr = qbds.addRange(fieldNum(InventJournalTrans, JournalId));

qbds1 = qbds.addDataSource(tableNum(InventTransOrigin));
qbr1 = qbds1.addRange(fieldNum(InventTransOrigin, InventTransId));


queryRun = new QueryRun(query);

while (
inventTrans = queryRun.get(tableNum(InventTrans));
inventDim = InventDim::find(inventTrans.InventDimId);




How to Get Financial Dimensions for a particular Customer using X++ code in Ax 2012

TWO Ways:

Way 1:

static void GetFinancialDimensionValue(Args _args)
CustTable custTable ;
DimensionAttributeValueSet DimensionAttributeValueSet;
DimensionAttributeValueSetItem DimensionAttributeValueSetItem;
DimensionAttributeValue DimensionAttributeValue;
DimensionAttribute DimensionAttribute;

while select * from custTable
where custTable .AccountNum == “CU0000001″
join RecId from DimensionAttributeValueSet
where DimensionAttributeValueSet.RecId == custTable .DefaultDimension
join RecId, DisplayValue from DimensionAttributeValueSetItem
where DimensionAttributeValueSetItem.DimensionAttributeValueSet == DimensionAttributeValueSet.RecId
join RecId from DimensionAttributeValue
where DimensionAttributeValue.RecId == DimensionAttributeValueSetItem.DimensionAttributeValue
join RecId, Name from DimensionAttribute
where DimensionAttribute.RecId == DimensionAttributeValue.DimensionAttribute
info(DimensionAttribute.Name+”—-“+ DimensionAttributeValueSetItem.DisplayValue);

Way 2:

static void GetFinancialDimensionValue1(Args _args)
CustTable custTable = CustTable::find(“CU0000001”);
DimensionAttributeValueSetStorage dimStorage;
Counter i;

dimStorage = DimensionAttributeValueSetStorage::find(custTable.DefaultDimension);

for (i=1 ; i<= dimStorage.elements() ; i++)

//if you want particular Dimension then put if condition like this
// {
info(strFmt(“%1 = %2”, DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name,



Ax 2012 Arrays

An array is a collection of variables that are all of the same type. The elements of an array are accessed with simple integer indexes.

There are three kinds of arrays:

  • Dynamic
  • Fixed-length
  • Partly on disk

X++ only supports one-dimensional arrays. It is possible, however, to mimic the behavior of multiple array indices.

Example JOB:

static void ArrayTypes(Args _args)
Name DynamicArray[];
Name FixedArray[4];
//Name PartllyOnDiskArray[,8]; // if you use like this then it is Dynamic array of Name only 8 in memory
Name PartllyOnDiskArray[16,8];// if you use like this then it is Fixed length array of Name wit 16 elements and 8 in memory

int i,j;
 CustTable custTable;

while select AccountNum from custTable
where custTable.CustGroup==”30″
DynamicArray[i] = custTable.AccountNum;

FixedArray[i] = custTable.AccountNum;

PartllyOnDiskArray[i] = custTable.AccountNum;

setPrefix(“Array Types”);
for (j=1;j<=dimOf(FixedArray);j++)
info(strFmt(“Fixed Array – %1”,FixedArray[j]));
setPrefix(“Dynamic Array”);
for (j=1;j<=dimOf(DynamicArray);j++)
info(strFmt(“Dynamic Array – %1”,DynamicArray[j]));
setPrefix(“PartlyOnDisk Array Memory value”);
for (j=1;j<=dimOf(PartllyOnDiskArray);j++)
info(strFmt(“PartlyOnDisk Array – %1”,PartllyOnDiskArray[j]));
setPrefix(“PartlyOnDisk Array fully printed (Disk + Memory)”);
for (j=1;j<=16;j++)
info(strFmt(“PartlyOnDisk Array – %1”,PartllyOnDiskArray[j]));


How can we validate our Customised/Standard( not in existing validation) field during Journal(Count & PL) validation and posting in Ax


When the journal is validated or posted from the post button on inventory journal or lines button on journal lines, inventory form, ensure that all the lines have adjustment code filled-in. if not, don’t post the journal and inform the user

Solution: apply the business logic in these class methods

## For Counting journal:


## For Profit Loss journal:

*First override the method — journalCheckTrans


## In General