AX 2012 - how to read a container

This question is answered

Hi,

I am trying to to see what inside the fields hash from the table DimensionAttributeValueSet¨.

I tried two methods but neither seems to be working. The first returns blanks and the second return blank in varaible a  and zeroes in variable b and c.

static void BcyrTest(Args _args)
{
   DimensionAttributeValueSet   dimset;

   str  a,b,c;

   while select * from dimset
   {
        //First method
       
      info(strFmt("dimension set = %1", con2str(dimset.Hash)));
       
       //second method
      [a,b,c] = dimset.Hash;

      info(strFmt(" dim = %1 - %2 -%3",a ,b,c ));
    }
}

Can somebody help me ?

 

Thanks.

 

Verified Answer
  • Thanks Martin.  I don't know why my code example got so 'mangled'.  I am going to attempt to post again.

    static void DavsHashValue(Args _args)
    {
        DimensionAttributeValueSet  davs;

        str                         a;
        container                   hash;

        while select davs
        {
            hash = davs.Hash;
            a = BinData::dataToString(hash);
            info(a);
        }

    }

All Replies
  • Hello,

    The value is actually a blob (put a breakpoint in your code, and watch the value in the debugger). Code as follows will return what you desire:

     

    static

     

     

     

    str a;

     

     

    container hash;

     

     

     

    while select davs

    {

    hash = davs.Hash;

    a = BinData::dataToString(hash);

    info(a);

    }

     

    }

     

    Best Regards,

    Bill Thompson

    Dynamics AX/Sure Step - Online Support Engineer

    ============================================================

    When responding to posts, please 'Reply to Group' via your newsreader so that

    others may learn and benefit from your issue.

    ============================================================

     

    This posting is provided 'AS IS' with no warranties, and confers no rights.

    ============================================================

    void DavsHashValue(Args _args)

    {

    DimensionAttributeValueSet davs;

     

     

     

  • It contains 160 bites of a SHA1 hash, so the question is how would you like to show the binary data. The usual way is to use a string of hexadecimal values - you can do it in this way:

    DimensionAttributeValueSet davs;
    Binary binary;
    int i;
    str hexaString;
    #define.SHA1Length(20)
        
    select firstOnly davs;
    binary = Binary::constructFromContainer(davs.Hash);
        
    for (i = 0; i < #SHA1Length; i++)
    {
        hexaString += int2Hex(binary.byte(i));
    }
    info(hexaString);

    Or, if you just want to look at the data and don't need it in code, you can look directly to SQL Server Management Studio.

    Martin "Goshoom" Dráb | Freelancer | Goshoom.NET Dev Blog

  • Ha! I looked for something like BinData::dataToString() but I failed to notice it. It's undoubtedly much simpler solution.

    Martin "Goshoom" Dráb | Freelancer | Goshoom.NET Dev Blog

  • Thanks Martin.  I don't know why my code example got so 'mangled'.  I am going to attempt to post again.

    static void DavsHashValue(Args _args)
    {
        DimensionAttributeValueSet  davs;

        str                         a;
        container                   hash;

        while select davs
        {
            hash = davs.Hash;
            a = BinData::dataToString(hash);
            info(a);
        }

    }