Specific Dimension on VendOpenTrans Grid

冷暖自知 提交于 2019-12-08 18:12:31

Selecting on specific dimension in AX 2012 is tricky beyond reason, but this method may be of help:

static void queryDimensionUpdate(LedgerDimensionAccount _dimension, Query _q, str _dataSourceName, FieldName _field = fieldStr(GeneralJournalAccountEntry,LedgerDimension))
{
    DimensionStorageSegment segment;
    DimensionStorage        storage = DimensionStorage::findById(_dimension);
    DimensionProvider       provider = new DimensionProvider();
    DimensionAttributeValue value;
    Name name;
    int segmentCount;
    int s;
    if (storage)
    {
        segmentCount = storage.segmentCount();
        for (s = 1; s <= segmentCount; s++)
        {
            segment = storage.getSegment(s);
            if (segment.parmDimensionAttributeValueId())
            {
                name = DimensionAttribute::find(DimensionAttributeValue::find(segment.parmDimensionAttributeValueId()).DimensionAttribute).Name;
                //info(strFmt('%1: %2, %3',  name,  segment.parmDisplayValue(), segment.getName()));
                provider.addAttributeRangeToQuery(_q, _dataSourceName, _field, DimensionComponent::DimensionAttribute, segment.parmDisplayValue(), name);
            }
        }
    }
}

Given a _dimension set with proper values to search for, say 011010-103-101--, it will update the query _q selecting for the dimensions given (011010, 103 and 101 in the example) related to the datasource _datasourceName and field _field.

It does so by iterating _dimension segments for values, then updating the query using the DimensionProvider.addAttributeRangeToQuery method.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!