Display method to get full LedgerDimension Name X++

public display str 1000 DimensionName()
{
    DimensionStorage        dimensionStorage;
    container               segments;
    int                     segmentCount, segmentIndex;
    DimensionStorageSegment segment;
    str 100                 segmentName, segmentValue,segmentDescription;


    if(this.LedgerDimension)
    {
        dimensionStorage = DimensionStorage::findById(this.LedgerDimension);
        segments = conNull();

    // Get segments
        segmentCount = dimensionStorage.segmentCountForHierarchy(dimensionStorage.hierarchyCount());
        for (segmentIndex = 1; segmentIndex <= segmentCount; segmentIndex++)
        {
            // Get segment
            segment = dimensionStorage.getSegmentForHierarchy(dimensionStorage.hierarchyCount(), segmentIndex);
            if (segment.parmDimensionAttributeValueId() != 0)
            {
                // Get segment name
                segmentName = DimensionAttribute::find(DimensionAttributeValue::find(segment.parmDimensionAttributeValueId()).DimensionAttribute).Name;
                // Add segment value
                segmentValue = segment.getName();
                if (segmentIndex == 1)
                {
                    segmentDescription = segmentValue;
                }
                else if(segmentDescription && (segmentIndex!=1))
                {
                    segmentDescription+=" - ";
                    segmentDescription +=segmentValue;
                }

            }

        }
    }
    return segmentDescription;
}

Leave Comment

Your email address will not be published. Required fields are marked *