Sunday, July 3, 2016

Get Dimension Hrchy

//get Dimension Hrchy by dimension Hrchy

static void GetDimensionHRCHy(Args _args)
{
    DimensionHierarchy              dimHierarchy;
    DimensionHierarchyLevel         dimHierarchyLevel;
    DimensionAttribute              dimAttribute;
    DimensionConstraintTree         conTree;
    DimensionConstraintNode         conNode;
    DimensionConstraintNodeCriteria conNodeCriteria;
    ;

    dimHierarchy    = DimensionHierarchy::find(5637148326);
    conTree         = DimensionConstraintTree::findByDimensionHierarchy(dimHierarchy.RecId);

    setPrefix('"' + dimHierarchy.Name + '"');

    while select dimHierarchyLevel
        order by Level
        where dimHierarchyLevel.DimensionHierarchy  == dimHierarchy.RecId
    {

        dimAttribute = DimensionAttribute::find(dimHierarchyLevel.DimensionAttribute);
        info(strFmt("Attribute at level %1 is %2",dimHierarchyLevel.Level,dimAttribute.Name));

        while select conNode
            order by Ordinal
            where   conNode.DimensionConstraintTree  == conTree.RecId
            &&      conNode.DimensionHierarchyLevel  == dimHierarchyLevel.RecId
        {

            while select conNodeCriteria
                where   conNodeCriteria.DimensionConstraintNode == conNode.RecId
            {
                if(conNodeCriteria.RangeFrom || conNodeCriteria.RangeTo)
                {
                    info(strFmt(" - Limited from %1 to %2",
                        conNodeCriteria.RangeFrom,
                        conNodeCriteria.RangeTo));
                }
                else
                    info(" - [No restriction]");
            }
        }
    }
}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...