1

I'm looking for a way to extract the values of column value stored in the SysLastValue table. i was trying to store it in txt file but the content of text file is unreadable

static void jobSettingStore(Args _args)
{
    syslastvalue sysLastValue;
    container dataContainer;
    BinData binData;        
    container blobContainer;
    ContainerClass containerClass;
    str settingsFileName = "c:\\settings.txt";       
    dataContainer = xSysLastValue::getValue(curExt(), curUserId(), UtilElementType::Usersetup, 'Mytable', 'myDesignName');        
    containerClass = new ContainerClass(dataContainer);
    blobContainer = containerClass.toBlob();        
    binData = new BinData();
    binData.setData(blobContainer);        
    binData.saveFile(settingsFileName);
}

Is there another way to store this value in an XML file?

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
Astoner
  • 55
  • 1
  • 9
  • Out of curiosity, why do you want to create an xml file? It if is to migrate form personalizations to another environment, like you hint at in [dynamics ax : Push Customized form to All users](http://stackoverflow.com/questions/32720711/dynamics-ax-push-customized-form-to-all-users?noredirect=1#comment53309732_32720711), you could also try [How to export/import from SysLastValue table](http://daxdilip.blogspot.de/2009/10/tip-how-to-exportimport-from.html) – FH-Inway Sep 23 '15 at 16:22
  • You should analyze the contents of the `container` and build an XML structure for these contents. The casting of a `container` to a `blob` will not magically create an XML file. – FH-Inway Sep 23 '15 at 16:26
  • @FH-Inway really i don't know to fix my broblem , just i want to extrat it to xml file to compare value of colomn in sysLAstValue .and my bit is get form setting from another user.now if i load personalisation form of an user my view of form can't change. hope you understand me – Astoner Sep 23 '15 at 16:40

1 Answers1

4

For most packed classes you can simply do a con2str of the container to get a readable content. This will not work if the container has nested containers. And user setup containers has!

It can be solved by using a recursive function:

static void con2xmlTest(Args _args)
{
    container con;

    str con2xml(container c, str ind = '', str sep = '  ')
    {
        int         idx = 0;
        int         len = conLen(c);
        str         tmp;
        str         retStr;
        while (idx < len)
        {
            idx += 1;
            if (typeOf(conPeek(c,idx)) == Types::Container)
                retStr += ind + sep + con2xml(conPeek(c,idx), ind+sep) + '\n';
            else
            {
                tmp = conPeek(c,idx);
                retStr += strFmt(ind + sep + '<%2>%1</%2>\n', tmp, typeOf(conPeek(c,idx)));
            }
        }
        return strFmt('<%2>\n%1</%2>', retStr + ind , Types::Container);
    }

    info(con2xml([1,2.0,["3",today()]]));
    con = xSysLastValue::getValue(curExt(), curUserId(), UtilElementType::Usersetup, 'CustTable', '');
    info(con2xml(con));
}

The output is readable except for humans.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50