2008-05-23

From Microsoft Dynamics AX Programming newsgroup tricks

TreeNode Alternative for FormControls

I want to create a Control on a Form just like I would with a TreeNode in AX 3.0. But the TreeNode.AOTAdd doesn't work for FOrmControls. Is there an Alternative how I can create a Control? These Fields should notbe temporary like in the Tutorial_Form_AddControl. They should be in the AOT after being created.

    TreeNode                formlist;
    Form                    formNode;

    FormBuildDesign         formDesign;

    ;

    formlist = infolog.findNode('Forms');
    formNode = formlist.AOTfindChild('Form1');

    formDesign = formNode.design();
    formDesign.addControl(FormControlType::String, 'StringEdit');
    formNode.save();
 

Saved form settings

When we import new objects, the user defined form settings are lost. It's possible to prevent that from happening?

static void JobSettingsStoringAndRestoring(Args _args)
{
    syslastvalue    sysLastValue;
    container       dataContainer;
    BinData         binData;

    container       blobContainer;
    ContainerClass  containerClass;
    str             settingsFileName = "c:\\settings.txt";
    ;

//  Store settings -->
    dataContainer = xSysLastValue::getValue(
        curExt(), curUserId(), UtilElementType::Usersetup, 'AddressCheck', 'myDesign');

    containerClass = new ContainerClass(dataContainer);
    blobContainer = containerClass.toBlob();

    binData = new BinData();
    binData.setData(blobContainer);

    binData.saveFile(settingsFileName);
//  Store settings <--

//  Restore settings -->
/*    binData = new BinData();
    binData.loadFile(settingsFileName);

    dataContainer = containerClass::blob2Container(binData.getData());
    xSysLastValue::putValue(dataContainer,
        curExt(), curUserId(), UtilElementType::Usersetup, 'AddressCheck', 'myDesign');*/
//  Restore settings <--
}
Copyright © 2008 Ruslan Goncharov

No comments: