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

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...