how to get all financial dimension with pipe delemeter in d365 fo x++

     public str getAllFinancialDimensions(RecId _defaultDimension)

    {

        DimensionAttributeValueSetStorage dimStorage;

        DimensionAttribute                 dimAttr;

        DimensionAttributeValue            dimAttrValue;

        DictTable                          dictTable;

        Common                             common;

        str                                result = '';

        str                                name, value, displayValue;;

        int                                i;


        dimStorage = DimensionAttributeValueSetStorage::find(_defaultDimension);


        for (i = 1; i <= dimStorage.elements(); i++)

        {

            dimAttrValue = DimensionAttributeValue::find(dimStorage.getValueByIndex(i));

            dimAttr      = DimensionAttribute::find(dimAttrValue.DimensionAttribute);


            if (dimAttr && dimAttrValue)

            {

                dictTable = new DictTable(dimAttr.BackingEntityType);

                common = dictTable.makeRecord();


                if (common.TableId)

                {

                    select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;

                    name  = common.(dimAttr.NameAttribute);  // readable name

                    value = common.(dimAttr.ValueAttribute); // actual dimension value


                    displayValue = strFmt("%1",value); // optional: include dimAttr.Name

                    result += (result == '' ? displayValue : ' | ' + displayValue);// build pipe-delimited string

                }

            }

        }


        return result;

    }

Comments

Popular posts from this blog

Get Current Worker data in d365 fo x++

Table Level Event Handler in d365 fo x++