Thursday, December 25, 2014

Sales order financial dimension update using code

We can use below code to update financial dimensions defaultDimension field of sales order using x++ code


static void setDefualtDimensionSO(Args _args)
{
    DimensionAttribute                  dimensionAttribute;
    DimensionAttributeValue             dimensionAttributeValue;
    DimensionAttributeValueSetStorage   dimensionStorage;
    SalesTable                          salesTable;
    Counter               i;  

    ttsBegin;
    select forupdate salesTable
        where salesTable.RecId == 5637146827;
    
   dimensionStorage = DimensionAttributeValueSetStorage::find(salesTable.defaultDimension);  
   dimensionAttribute = DimensionAttribute::findByName('Handling');  
   dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, 'BROK', true, true);  
   dimensionStorage.addItem(dimensionAttributeValue);  
   
    
    salesTable.defaultDimension = dimensionStorage.save();  
    salesTable.update();
    ttsCommit;

}

No comments:

Post a Comment