03 June 2015

DefaultDimension and default financial dimension values through X++ code in AX 2012

Using the dimension values getting default dimension recid:
Example 1.
static void dimension(Args _args)
{
DefaultDimensionView defaultDimensionView,defaultDimensionView1;
VendInvoiceTrans vendInvoiceTrans;

while select defaultDimensionView join vendInvoiceTrans
where vendInvoiceTrans.DefaultDimension == defaultDimensionView.DefaultDimension
&& defaultDimensionView.name == "CostCode"
&& defaultDimensionView.DisplayValue == "DX001"
join defaultDimensionView1
where defaultDimensionView1.DefaultDimension == vendInvoiceTrans.DefaultDimension
&& defaultDimensionView1.Name == "Project"
&& defaultDimensionView1.DisplayValue == "TIPL-000044"
{
info(strfmt("%1 %2 ",defaultDimensionView.DisplayValue,vendInvoiceTrans.InvoiceId));

}

}
=============
Using Defult dimension getting Dimension values: Example 1:

ProjTable ProjTable;
DimensionAttributeValueSet DimensionAttributeValueSet;
DimensionAttributeValueSetItem DimensionAttributeValueSetItem;
DimensionAttributeValue DimensionAttributeValue;
DimensionAttribute DimensionAttribute;

while select * from ProjTable
where ProjTable.ProjId == "70001" // To get 70001 dimension values
join RecId from DimensionAttributeValueSet
where DimensionAttributeValueSet.RecId == ProjTable.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);
}


===============


DimensionAttributeValueSetStorage dimStorage;
ProjTable ProjTable;
Counter i;

ProjTable = ProjTable::find("70001"); // To get 70001 dimension values
dimStorage = DimensionAttributeValueSetStorage::find(ProjTable.DefaultDimension);

for (i=1 ; i<= dimStorage.elements() ; i++) { info(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name +"----" +dimStorage.getDisplayValueByIndex(i)); } ============= ProjTable ProjTable; Counter i; container conDim; ProjTable = ProjTable::find("70001"); // To get the dimension values for 70001 conDim = AxdDimensionUtil::getDimensionAttributeValueSetValue(ProjTable.DefaultDimension);

for (i=1 ; i<= conLen(conDim) ; i++)
{
info(conPeek(conDim,i));
}

No comments:

Post a Comment

Give me the commetns and solutions

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension-...