Search your query

Wednesday, January 25, 2023

Fetch and Display Dimension Description (Name) based on Dimension Id:


Create class for display method.

[ExtensionOf(tableStr(TableNameHere!))]

final Public class TableNameHere!_Extension

{

    [SysClientCacheDataMethodAttribute(true)]

    display public static Name displayDepartmentDimensionDescription(TableNameHere! _this)

    {

        DimensionAttributeValueSetStorage   dimStorage;

        DimensionAttribute                  dimAttr;

        DimensionAttributeValue             dimAttrValue;

        Name                                dimDescription;

       

        int i;

        DictTable                   dictTable;

        Common                      common;

 

        dimStorage = DimensionAttributeValueSetStorage::find(_this.DefaultDimension);

 

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

        {

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Department")

            {

                // get attribute select here.

                select firstonly dimAttrValue

                      where dimAttrValue.RecId == dimStorage.getValueByIndex(i)

                 join dimAttr

                        where dimAttr.RecId == dimAttrValue.DimensionAttribute;

 

                if (dimAttr && dimAttrValue)

                {

                    dictTable = new DictTable(dimAttr.BackingEntityType);

                    common = dictTable.makeRecord();

 

                    if (common.TableId)

                    {

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

                        dimDescription = common.(dimAttr.NameAttribute);

                    }

                }

          

            }

        }

 

        return dimDescription;

    }

No comments:

Post a Comment