Specific Dimension on VendOpenTrans Grid

流过昼夜 提交于 2019-12-08 05:57:55

问题


My task is to add a field in VendOpenTrans with a specific Dimension. I have added to my DataSources in VendOpenTrans tables DimensionAttributeValueSet, DimensionAttributeValueSetItem, DimensionAttributeValue and DimensionAttribute.

In their properties I have made joins (join source) with InnerJoin LinkType (I tried all of the options here). Then I have add a field on my grid from DimensionAttributeValueSetItem -> DisplayValue (field name).

And now in ExecuteQuery method of VendOpenTrans I add a code:

public void executeQuery()
{
    /*QueryBuildRange dimensionAttributeValueSetRange;
    ;
    dimensionAttributeValueSetRange = this.query().dataSourceTable(tableNum(DimensionAttribute)).addRange(fieldNum(DimensionAttribute, Name ));
    dimensionAttributeValueSetRange.value('MyDimensionName');
    super();
}

The final result of this is that I have a new filter with my dimension. So I don't see on my grid records that have an empty value in this dimension.

The thing that I want to achieve is to show the value of "MyDimensionName" if It's filled but when It's not record should be shown with just an empty value...

I spend on this many many hours and I still didn't work it out...


回答1:


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.



来源:https://stackoverflow.com/questions/31156695/specific-dimension-on-vendopentrans-grid

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