Thursday, November 15, 2012

Create a New Table and Field by using X++ code


static void Job36(Args _args)
{
    SysDictTable sysdictTable;

    treenode trv;

    AOTTableFieldList fieldnode;

    #AOT

    trv = treenode::findNode(#TablesPath);

    // adding table

    trv.AOTadd('MS_IT_TestCompanyAddress');

    trv = trv.AOTfindChild('MS_IT_TestCompanyAddress');

    trv.AOTcompile(1);

    trv.AOTsave();

    trv.AOTfindChild('MS_IT_TestCompanyAddress');

    fieldnode = trv.AOTfirstChild();

    // adding fields

    fieldnode.addString('GLCompanyAddressNbr');

    fieldnode.addString('AddressOneText');

    fieldnode.addString('StateProvinceCode');

    fieldnode.addString('PostalCode');

    fieldnode.addString('CityName');

    fieldnode.addString('DistrictName');

    fieldnode.addString('AddressPhoneNbr');

    fieldnode.addString('FaxNbr');

    trv.AOTcompile(1);
}

No comments: