Interview Questions

Tuesday, September 27, 2016

AX2012- Update/Change FinancialDimension value in X++ code

static void PSV_UpdateOpDivDimension_Items(Args _args)

InventTable inventTable; 
DimensionAttributeValueSetStorage dimStorage; 
DimensionAttribute dimAttrOpDiv; 
DimensionAttributeValue dimAttributeValue;
changeCompany('DAT') 
{
while select forUpdate inventTable 
{
ttsBegin;
dimStorage = DimensionAttributeValueSetStorage::find(inventTable.DefaultDimension);
dimAttrOpDiv = DimensionAttribute::findByName("Operating_Division");

dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrOpDiv, 'NewValue', true, true);

dimStorage.addItem(dimAttributeValue); 
inventTable.DefaultDimension = dimStorage.save(); 
inventTable.doUpdate();
ttsCommit;


}

//This code updates the items financial dimensions to new values.

No comments:

Post a Comment