Monday, 26 May 2014

Restrict the Page header part of report to open on next page in ax 2009


Write the below code on header method . override executeSection() method.


public void executeSection()
{
if(element.page() == 1)
super();
}

Restrict User to enter only 10 digit numeric values in a string field on a Table.


public boolean validateField(FieldId _fieldIdToCheck)
{
boolean ret;
int q;
int ascii;
int i;
q= strLen(this.Phone);
ret = super(_fieldIdToCheck);
if(this.Phone)
{
for (i=1; i<=q; i++)
{
ascii = char2num(this.Phone, i);
if( ascii >= 48 && ascii <= 57)
ret = true;
else
{
ret = false;
error(‘Phone Number must be numeric only’);
break;
}
}
if(q!=10)
{
error(‘Phone Number must be of 10 digits’);
this.Phone = “”;
this.insert();
}
}
return ret;
}

Tuesday, 25 March 2014

Browse File in ax 2012

static void Select_FileOpen(Args _args)
{
/*
This is the demonstration to select the file as a browser window
you can create fileOpen browser window
*/
Dialog dialog;
DialogField dialogField;
Filename filename;
;
dialog = new Dialog(“FileOpen”);
dialogfield = dialog.addField(extendedTypeStr(Filenameopen), “File Name”);
dialog.run();
if (dialog.run())
{
filename = (dialogfield.value());
}
info(filename);
}

Show (store/retrieve) Image on grid manually in ax 2012

Step 1 : Create a table and take Container type field  and extend it with Bitmap edt.
Image
Step 2: Create a Form  and drag & drop your field on that form Grid.
Capture2
Step 3: Now go to  window control > Methods > Override method > douseDblClick
Capture3
Now put the below code in these method
public int mouseDblClick(int _x, int _y, int _button, boolean _Ctrl, boolean _Shift)
{
int ret;
str imageFilePathName;
container imageContainer;
FilenameFilter filter = ['Image Files','*.bmp; *.jpg; *.gif; *.jpg'];
BinData bindata = new BinData();
str extension, path, nameOfFile;
ret = super(_x, _y, _button, _Ctrl, _Shift);
imageFilePathName = WinAPI::getOpenFileName(element.hWnd(),filter,”,”,”,”);
if (imageFilePathname && WinAPI::fileExists(imageFilePathName))
{
[path, nameOfFile, extension] = fileNameSplit(imageFilePathName);
if (extension == ‘.bmp’ ||
extension == ‘.jpg’ ||
extension == ‘.gif’ ||
extension == ‘.jpeg’)
{
binData.loadFile(imageFilePathName);
imageContainer = binData.getData();
ImageTable.Image = imageContainer; //Here ImageTable is your table name
}
}
ImageTable_ds.research(); // ImageTable_ds is your datasource name.
return ret;
}
Save all and open form ImageTable.
Capture4
Step 4 : Double Click on field and select image. you will see your form like these.
Capture5
You can do the same thing with button too.
I used Change for the same. write your code on Click method of button.
Thanks.

Monday, 24 March 2014

How to convert Class File to XML file in Ax 2012

static void ClassToXml(Args _args)
{

    SysDictClass sysDictClass  = new SysDictClass(1023902);// used to find the class using classid
    TreeNode    treeNode = TreeNode::findNode(sysDictClass.path()); // to find the class in AOT
    TreeNode    childNode;
    int         counter=1;// used to count No of child nodes in the class
    str         nodename; // used to store the node name
    XmlTextWriter xmlDoc; // used to write xml file

    xmlDoc =XmlTextWriter::newFile("D:\Test.xml"); // creating xml file
    xmlDoc.writeStartDocument(); // writing xml docuemnt starting tag
    xmlDoc.writeStartElement("ClassInformation"); // root node
    xmlDoc.writeAttributeString("ClassName",sysDictClass.name()); // root node attirbutes

    if (treenode) // If  class is avilable
    {
        info(strfmt('number of methods in a classe: %1',treenode.aotchildnodecount()));
        childnode = treenode.aotfirstchild();
        while(counter <= treenode.aotchildnodecount())
        {
            xmlDoc.writeStartElement("MethodInformation");
            xmlDoc.writeAttributeString("MethodName",childNode.treeNodeName());
            xmlDoc.writeElementString("MethodContent",childNode.AOTgetSource());
            xmlDoc.writeEndElement();
            childnode = childnode.aotnextsibling(); // gets the next node
            counter++; // increments the counter by 1
        }
    }
    XMLDoc.writeEndElement(); // writes the End Tag
    xmlDoc.writeEndDocument(); // docuemnt ending.
    info("XML File is Created in D Drive");
}

Tuesday, 18 March 2014

How to create Form using X++ in ax 2012.

static void createFormPk()
{
Args args;
Form form;
FormRun formRun;
FormBuildDesign fbDesign;
FormBuildDataSource fbDS;
FormBuildGridControl fbGrid;
FormBuildStringControl fbStr1;
FormBuildStringControl fbStr2;
FormBuildTabControl fbTab;
FormBuildTabPageControl fbTabPage1;
FormBuildTabPageControl fbTabPage2;
DictTable dictTable;
int idx, idx2, idx3;
FormControlType fctTabPage = FormControlType::TabPage;
FormControlType fctTab = FormControlType::Tab;
FormControlType fctGrid = FormControlType::Grid;
FormControlType fctString = FormControlType::String;
// Create the form header.
form = new Form();
// Add a data source to the form.
dictTable = new DictTable(tablenum(CustTable));
fbDS = form.addDataSource(dictTable.name());
fbDS.table(dictTable.id());
// Create the form design.
fbDesign = form.addDesign("Design");
fbDesign.caption("Customer information Pk");
// Add tab
fbTab = fbDesign.addControl(fctTab, "Overview");
// Add tab pages
fbTabPage1 = fbTab.addControl(fctTabPage, "Overview");
fbTabPage1.caption("Overview");

    fbTabPage2 = fbTab.addControl(fctTabPage,"General");
fbTabPage2.caption("General");
// Add grid onto tab 1 and data fields onto grid.
fbGrid = fbTabPage1.addControl(fctGrid,"Table Grid");
fbGrid.addDataField(fbDS.id(),
dictTable.fieldName2Id("AccountNum"));
fbGrid.addDataField(fbDS.id(),
dictTable.fieldName2Id("CustGroup"));
fbGrid.addDataField(fbDS.id(),
dictTable.fieldName2Id("Currency"));
// Add string fields to tab 2, and assign datasource
fbStr1 = fbTabPage2.addControl(fctString,"String 1");
fbStr1.dataSource(fbDS.id());
fbStr1.dataField(dictTable.fieldName2Id("AccountNum"));
fbStr2 = fbTabPage2.addControl(fctString,"String 2");
fbStr2.dataSource(fbDS.id());
fbStr2.dataField(dictTable.fieldName2Id("CustGroup"));
// Create the run-time form.
args = new Args();
args.object(form);
formRun = classfactory.formRunClass(args);
formRun.run();
formRun.detach();
}

How to Enable Disable Button Of list page using interaction class in ax 2012

Listpage interaction class: example

Listpage interaction class:( S3HrLeaveResquestListPageInteraction-interaction class,
S3HRLeaveRequestListPage-listpage name , DeleteCommandButton-button name(autodeclaration yes),
S3HRLeaveRequestListPage-listpage query, S3HRLeaveRequest_1-listpage table)


Create New Class & Write below code:=

public class S3HrLeaveResquestListPageInteraction extends SysListPageInteractionBase
{
    S3HRLeaveRequest S3HRLeaveRequest;
}


public void selectionChanged()
    {
S3HRLeaveRequest leaverequestCurrent = this.listPage().activeRecord(queryDataSourceStr(S3HRLeaveRequestListPage, S3HRLeaveRequest_1));
super();
 if(leaverequestCurrent.LeaveRequestApprovalStatus ==              S3HRLeaveRequestApproval::NotSubmitted)
        {
          this.listPage().actionPaneControlEnabled(formControlStr(S3HRLeaveRequestListPage,             DeleteCommandButton), true);
        }
        else
        {
            this.listPage().actionPaneControlEnabled(formControlStr(S3HRLeaveRequestListPage,             DeleteCommandButton), false);
        }
    }

Now extend this class to the form.


Friday, 21 February 2014

How to get SID of ax user system in ax 2012

static void GetUserSID(Args _args)
{
str windowsUser = 'anshuljain.in\\anshul.jain'; // DomainName\\userId
#Aif
#File
networkALias alias;
networkDomain domain;

int pos, len;
sid userSid;
Microsoft.Dynamics.IntegrationFramework.Util util;
;
//Split the windowsUser into domain and alias
len = strlen(windowsUser);
pos = strfind(windowsUser, #FilePathDelimiter, 1,len);
domain = substr(windowsUser, 1, pos-1);
alias = substr(windowsUser, pos+1, len - pos);

new InteropPermission(InteropKind::ClrInterop).assert();
// BP Deviation Documented
util = new Microsoft.Dynamics.IntegrationFramework.Util();

//Get the Windows SID for this user
// BP Deviation Documented
userSid = util.GetUserSid(domain, alias);
CodeAccessPermission::revertAssert();

info(userSid);
}

Thursday, 20 February 2014

How to perform a successful round in AX from real to integer?

static void Job(Args _args)
{
    int amount1, amount2;
    real amount1 = 785.78, amount2 = 450.35;
    ;
    amount1 = decround(amount1, 0);
    amount2 = decround(amount2, 0);
    // It shows 786, 450
    info(strfmt("%1, %2", amount1, amount2));
}

Export Data to Excel file in AX 2012

static void ExportImportData(Args _args)
{
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorkSheets xlsWorkSheetCollection;
SysExcelWorkSheet xlsWorkSheet;
SysExcelRange xlsRange;
ExportImportRecords exportImportRecords; //Table used to export data
int row = 1;
str fileName;
;
fileName = “C:\\Libraries\Documents\exportImportRecords.xlsx”;
xlsApplication = SysExcelApplication::construct();
//Create Excel WorkBook and WorkSheet
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBook = xlsWorkBookCollection.add();
xlsWorkSheetCollection = xlsWorkBook.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);
xlsWorkSheet.cells().item(row,1).value(“Account Num”);
xlsWorkSheet.cells().item(row,2).value(“Name”);
xlsWorkSheet.cells().item(row,3).value(“Phone”);
row++;
while select exportImportRecords
{
if(row == 10)
break;
xlsWorkSheet.cells().item(row,1).value(exportImportRecords.ID);
xlsWorkSheet.cells().item(row,2).value(exportImportRecords.Name);
xlsWorkSheet.cells().item(row,3).value(exportImportRecords.Phone);
row++;
}
if(WinApi::fileExists(fileName))
WinApi::deleteFile(fileName);
xlsApplication.visible(true);
info(“Export Completed”);
}

Import Data from Excel File in AX 2012

static void importRecord(Args _args)
{
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorksheets xlsWorkSheetCollection;
SysExcelWorksheet xlsWorkSheet;
SysExcelRange xlsRange;
SysExcelCells Cells;
SysExcelCell RCell;
CommaIO inFile;
int nRow,i;
DialogField dialogPath;
Dialog dialog;
Filename filename;
Name Name;
ID ID;
Phone Phone;
income income;
importrecord exportImportRecords; //Table used to store data
;
dialog = new Dialog(“Import”);
dialogPath = dialog.addField(extendedTypeStr(Filenameopen), “File Name”);
dialog.run();
if (dialog.run())
{
filename = (dialogPath.value());
}
inFile = new CommaIO (filename, ‘R’);
if (!inFile || infile.status() != IO_Status::Ok )
{
throw error (strfmt(“@SYS19312″,filename));
}
try
{
xlsApplication = SysExcelApplication::construct();
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBookCollection.open(filename);
xlsWorkSheetCollection = xlsApplication.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);
Cells = xlsWorkSheet.Cells();
nRow = 2;
RCell = Cells.Item(nRow, 1);
while (RCell.value().bstr() != “”)
{
ID = any2int(RCell.value().bStr());
RCell = Cells.item(nRow,2);
Name = RCell.value().bStr();
RCell = Cells.item(nRow,3);
Phone = RCell.value().bStr();
RCell = Cells.item(nRow,4);
income = any2real(RCell.value().bStr());
exportImportRecords.ID = ID;
exportImportRecords.Name = Name;
exportImportRecords.Phone = Phone;
exportImportRecords.income = income;
exportImportRecords.insert();
nRow++;
RCell = Cells.Item(nRow, 1);
}
xlsApplication.quit ();
xlsApplication.finalize ();
info(“Import completed”);
}
catch( Exception::Error)
{
xlsApplication.quit ();
xlsApplication.finalize ();
ttsabort;
info(“Unable to process the excel import “);
}
}

How to create XML file through code in Ax 2012

static void ExportXML(Args _args)
{
    XmlDocument     doc;
    XmlElement      nodeXml;
    XmlElement      nodeTable;
    XmlElement      nodeAccount;
    XmlElement      nodeName;
    XmlFile            xmlFile; // Table Name

    #define.filename(@' D:\XMLFile.xml')

    doc = XmlDocument::newBlank();
    nodeXml = doc.createElement('xml');
    doc.appendChild(nodeXml);
    while select RecId,Id, Name,Phone from xmlFile
    {
    nodeTable = doc.createElement(tableStr(XmlFile));
    nodeTable.setAttribute(fieldStr(XmlFile, RecId),
    int642str(xmlFile.RecId));
    nodeXml.appendChild(nodeTable);
    nodeAccount = doc.createElement(fieldStr(XmlFile, Id));
    nodeAccount.appendChild(doc.createTextNode(xmlFile.Id));
    nodeTable.appendChild(nodeAccount);
    nodeName = doc.createElement(fieldStr(XmlFile, Name));
    nodeName.appendChild(doc.createTextNode(xmlFile.Name));
    nodeTable.appendChild(nodeName);
    nodePhone = doc.createElement(fieldStr(XmlFile, Phone));
    nodePhone.appendChild(doc.createTextNode(xmlFile.Phone));
    nodeTable.appendChild(nodePhone);
    }
    doc.save(#filename);
    info(strFmt("File %1 created.", #filename));
    }

Update Records of an existing Item in ax 2012

static void UpdateImportItem(Args _args)
{
    SysExcelApplication                       xlsApplication;
    SysExcelWorkBooks                         xlsWorkBookCollection;
    SysExcelWorkBook                          xlsWorkBook;
    SysExcelWorksheets                        xlsWorkSheetCollection;
    SysExcelWorksheet                         xlsWorkSheet;
    SysExcelRange                             xlsRange;
    SysExcelCells                             Cells;
    SysExcelCell                              RCell;
    CommaIO                                   inFile;
    int                                       nRow,i;
    DialogField                               dialogPath;
    Dialog                                    dialog;
    Filename                                  filename;

    EcoResProductMaster                       ecoResProductMaster;
    EcoResProductIdentifier                   ecoResProductIdentifier;
    EcoResProductDimensionGroupProduct        ecoResProductDimensionGroupProduct;
    EcoResProductMasterModelingPolicy         ecoResProductMasterModelingPolicy;
    EcoResStorageDimensionGroupProduct        ecoResStorageDimensionGroupProduct;
    EcoResTrackingDimensionGroupProduct       ecoResTrackingDimensionGroupProduct;
    EcoResConfiguration                       ecoResConfiguration;
    EcoResProductMasterConfiguration          ecoResProductMasterConfiguration;
    EcoResDistinctProductVariant              ecoResDistinctProductVariant;
    EcoResProductVariantConfiguration         ecoResProductVariantConfiguration;

    InventTable                               inventTable;
    InventTableModule                         inventTableModule;
    InventItemSetupSupplyType                 inventItemSetupSupplyType;

    EcoResStorageDimensionGroupItem           ecoResStorageDimensionGroupItem;
    EcoResTrackingDimensionGroupItem          ecoResTrackingDimensionGroupItem;

    InventModelGroupItem                      inventModelGroupItem;
    InventItemGroupItem                       inventItemGroupItem;

    InventDim                                 inventDim;
    InventDimCombination                      inventDimCombination;

    //PdsCWProduct                              pdsCWProduct;
    EcoResProductDisplayProductNumber         ecoResProductDisplayProductNumber;
    EcoResProductSearchName                   ecoResProductSearchName;
    EcoResProductType                         ecoResProductType;
    EcoResDistinctProduct                     ecoResDistinctProduct;

    //Traslation
    EcoResProductTranslation                  ecoResProductTranslation;
    LanguageId                                LanguageId;
    EcoResProductName                         ecoResProductName;
    EcoResDescription                         ecoResDescription;
    //EcoResProductDimensionGroup
    EcoResProductDimensionGroup               ecoResProductDimensionGroup;
    EcoResProductDimensionGroupName           ecoResProductDimensionGroupName;
    Description                               description;
    //EcoResStorageDimensionGroup
    EcoResStorageDimensionGroup               ecoResStorageDimensionGroup;
    EcoResStorageDimensionGroupName           ecoResStorageDimensionGroupName;
    //Description                               description;
    //EcoResTrackingDimensionGroup
    EcoResTrackingDimensionGroup              ecoResTrackingDimensionGroup;
    EcoResTrackingDimensionGroupName          ecoResTrackingDimensionGroupName;
    //EcoResProductMaster
    //RetailColorGroupId                        retailColorGroupId;
    //RetailSizeGroupId                         retailSizeGroupId;
    //RetailStyleGroupId                        retailStyleGroupId;
    EcoResVariantConfigurationTechnologyType  ecoResVariantConfigurationTechnologyType;
    ;
    dialog = new Dialog("Import");
    dialogPath = dialog.addField(extendedTypeStr(Filenameopen), "File Name");
    dialog.run();
    if (dialog.run())
    {
        filename = (dialogPath.value());
    }
    inFile = new CommaIO (filename, 'R');
    if (!inFile || infile.status() != IO_Status::Ok )
    {
        throw error (strfmt("@SYS19312",filename));
    }
    try
    {
        xlsApplication          = SysExcelApplication::construct();
        xlsWorkBookCollection   = xlsApplication.workbooks();
        xlsWorkBookCollection.open(filename);
        xlsWorkSheetCollection  = xlsApplication.worksheets();
        xlsWorkSheet            = xlsWorkSheetCollection.itemFromNum(1);
        Cells                   = xlsWorkSheet.Cells();
        nRow = 2;
        RCell = Cells.Item(nRow, 1);
        while (RCell.value().bStr() != "")
        {
            ecoResProductDisplayProductNumber = RCell.value().bStr();
            RCell  = Cells.item(nRow,2);
            //pdsCWProduct = any2enum( RCell.value().bStr());
            RCell  = Cells.item(nRow,3);
            ecoResProductType =str2enum(ecoresproducttype, RCell.value().bStr());
            RCell  = Cells.item(nRow,4);
            ecoResProductSearchName   = RCell.value().bStr();
            RCell  = Cells.item(nRow,5);
            ecoResProductName   = RCell.value().bStr();
            RCell  = Cells.item(nRow,6);
            ecoResDescription   = RCell.value().bStr();
            RCell  = Cells.item(nRow,7);
            LanguageId   = RCell.value().bStr();
            RCell  = Cells.item(nRow,8);
            ecoResProductDimensionGroupName   = RCell.value().bStr();
            RCell  = Cells.item(nRow,9);
            description = RCell.value().bStr();
            RCell  = Cells.item(nRow,10);
            ecoResStorageDimensionGroupName = RCell.value().bStr();
            RCell  = Cells.item(nRow,11);
            description = RCell.value().bStr();
            RCell  = Cells.item(nRow,12);
            ecoResTrackingDimensionGroupName = RCell.value().bStr();
            RCell  = Cells.item(nRow,13);
            description = RCell.value().bStr();
            RCell  = Cells.item(nRow,14);
            //retailColorGroupId = RCell.value().bStr();
            RCell  = Cells.item(nRow,15);
            //retailSizeGroupId = RCell.value().bStr();
            RCell  = Cells.item(nRow,16);
            //retailStyleGroupId = RCell.value().bStr();
            RCell  = Cells.item(nRow,17);
            ecoResVariantConfigurationTechnologyType = str2enum(ecoResVariantConfigurationTechnologyType, RCell.value().bStr());
            nRow++;
            RCell = Cells.Item(nRow, 1);
        }
        xlsApplication.quit ();
        xlsApplication.finalize ();
       // info("Import completed");
    }
    catch( Exception::Error)
    {
        //Close Excel.
        xlsApplication.quit ();
        xlsApplication.finalize ();
        ttsabort;
        info("Unable to process the excel import ");
    }

    try
    {
        //ProductMaster
      //  ecoResProductMaster.clear();
      //  ecoResProductMaster.initValue();
        select forUpdate RecId from ecoResProductMaster where ecoResProductMaster.DisplayProductNumber== ecoResProductDisplayProductNumber;
        {
        ecoResProductMaster.ProductType = ecoResProductType;
        ecoResProductMaster.DisplayProductNumber = ecoResProduct::findByProductNumber(ecoResProductDisplayProductNumber).DisplayProductNumber;
        ecoResProductMaster.SearchName = ecoResProductSearchName;
        ecoResProductMaster.VariantConfigurationTechnology = ecoResVariantConfigurationTechnologyType;
        //ecoResProductMaster.RetailColorGroupId = retailColorGroupId;
        //ecoResProductMaster.RetailSizeGroupId = retailSizeGroupId;
       // ecoResProductMaster.RetailStyleGroupId = retailStyleGroupId;

     //   if (ecoResProductMaster.validateWrite())
      //  {
            ecoResProductMaster.update();
          //  ecoResProductIdentifier.clear();
       //     ecoResProductIdentifier.initValue();
           select forUpdate RecId from  ecoResProductIdentifier where ecoResProductIdentifier.Product == ecoResProductMaster.RecId;
          {
            ecoResProductIdentifier.ProductNumber = ecoResProductDisplayProductNumber;
           // ecoResProductIdentifier.update();
          }
            //Product dimension group
           // ecoResProductDimensionGroupProduct.clear();
           // ecoResProductDimensionGroupProduct.initValue();
           // ecoResProductDimensionGroupProduct.initFromProduct(ecoResProductMaster);
            ecoResProductDimensionGroupProduct.ProductDimensionGroup = EcoResProductDimensionGroup::findByDimensionGroupName(ecoResProductDimensionGroupName).RecId;
           // if (ecoResProductDimensionGroupProduct.validateWrite())
            //{
             //   ecoResProductDimensionGroupProduct.update();
            //}

            //Storage dimension group
         //   ecoResStorageDimensionGroupProduct.clear();
         //   ecoResStorageDimensionGroupProduct.initValue();
          select forUpdate RecId from ecoResStorageDimensionGroupProduct where  ecoResStorageDimensionGroupProduct.Product == ecoResProductMaster.RecId;
            ecoResStorageDimensionGroupProduct.StorageDimensionGroup = EcoResStorageDimensionGroup::findByDimensionGroupName(ecoResStorageDimensionGroupName).RecId;
           // if (ecoResStorageDimensionGroupProduct.validateWrite())
           // {
              //  ecoResStorageDimensionGroupProduct.update();
           // }

            //Tracking dimension group
          //  ecoResTrackingDimensionGroupProduct.clear();
          //  ecoResTrackingDimensionGroupProduct.initValue();
            select forUpdate RecId from ecoResTrackingDimensionGroupProduct where ecoResTrackingDimensionGroupProduct.Product == ecoResProductMaster.RecId;
            ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup = EcoResTrackingDimensionGroup::findByDimensionGroupName(ecoResTrackingDimensionGroupName).RecId;
            //if (ecoResTrackingDimensionGroupProduct.validateWrite())
           // {
               // ecoResTrackingDimensionGroupProduct.update();
           // }

            //Product modeling policy
         //   ecoResProductMasterModelingPolicy.clear();
         //   ecoResProductMasterModelingPolicy.initValue();
           // ecoResProductMasterModelingPolicy.ProductMaster == ecoResProductMaster.RecId;
          //  if (ecoResProductMasterModelingPolicy.validateWrite())
          //  {
                //ecoResProductMasterModelingPolicy.update();
          //  }

            //Product translation
            EcoResProductTranslation::createOrUpdateTranslation(ecoResProductMaster.RecId, ecoResProductName, ecoResDescription);

            //Configuration
            ecoResConfiguration = EcoResConfiguration::findByName(description);
            if (!ecoResConfiguration)
            {
               // ecoResConfiguration.clear();
                //ecoResConfiguration.initValue();
                ecoResConfiguration.Name = description;
               // ecoResConfiguration.update();
            }

            //Configuration assigned to product master
            //ecoResProductMasterConfiguration.clear();
           // ecoResProductMasterConfiguration.initValue();
          select forupdate RecId    from ecoResProductMasterConfiguration where ecoResProductMasterConfiguration.Configuration == ecoResConfiguration.RecId;
          //  ecoResProductMasterConfiguration.Configuration = ecoResConfiguration.RecId;
          {
            ecoResProductMasterConfiguration.Description = description;
            ecoResProductMasterConfiguration.ConfigProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, ConfigId));
            ecoResProductMasterConfiguration.ConfigProductMaster = ecoResProductMaster.RecId;
          //  ecoResProductMasterConfiguration.update();
          }
            //Product variant
          //  ecoResDistinctProductVariant.clear();
          //  ecoResDistinctProductVariant.initValue();
            ecoResDistinctProductVariant.DisplayProductNumber = EcoResProductNumberBuilderVariant::buildFromProductNumberAndDimensions(
            ecoResProductMaster.productNumber(),
            EcoResProductVariantDimValue::getDimensionValuesContainer(description, "", ""));
            ecoResDistinctProductVariant.SearchName = ecoResProductMaster.SearchName + ecoResProductSearchName/*ConfigId*/;
            ecoResDistinctProductVariant.ProductType = ecoResProductMaster.ProductType;
            ecoResDistinctProductVariant.ProductMaster = ecoResDistinctProductVariant::find(ecoResProductMaster.RecId).ProductMaster;
           // ecoResDistinctProductVariant.update();

            //Product variant configuration
          //  ecoResProductVariantConfiguration.clear();
          //  ecoResProductVariantConfiguration.initValue();
            ecoResProductVariantConfiguration.initFromDistinctProductVariant(ecoResDistinctProductVariant);
            ecoResProductVariantConfiguration.ProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, ConfigId));
            ecoResProductVariantConfiguration.Configuration = ecoResConfiguration.RecId;
          //  ecoResProductVariantConfiguration.update();

            //Product variant translation
            EcoResProductTranslation::createOrUpdateTranslation(ecoResDistinctProductVariant.RecId, ecoResProductName, ecoResDescription);
            }
            //Released product
           // inventTable.clear();
           // inventTable.initValue();
            inventTable.initFromEcoResProduct(ecoResProductMaster);
            select forupdate RecId from inventTable where inventTable.ItemId == ecoResProductDisplayProductNumber;
          {
          inventTable.NameAlias = ecoResProductSearchName;
           // if (inventTable.validateWrite())
           // {
               // inventTable.update();
              }
                //Inventory model group
               // inventModelGroupItem.clear();
              //  inventModelGroupItem.initValue();
              select forUpdate RecId from inventModelGroupItem where inventModelGroupItem.ItemId == inventTable.ItemId;
               {
                inventModelGroupItem.ItemDataAreaId = inventTable.dataAreaId;
                //inventModelGroupItem.ItemId = inventTable.ItemId;
                inventModelGroupItem.ModelGroupId = "FIFO";
                inventModelGroupItem.ModelGroupDataAreaId = curext();
               // inventModelGroupItem.update();
              }

                //Item group
               // inventItemGroupItem.clear();
                //inventItemGroupItem.initValue();
            select forUpdate RecId from inventItemGroupItem where   inventItemGroupItem.ItemId == inventTable.ItemId;
              {
                inventItemGroupItem.ItemDataAreaId = inventTable.dataAreaId;
                //inventItemGroupItem.ItemId = inventTable.ItemId;
                inventItemGroupItem.ItemGroupId = "Parts";
                inventItemGroupItem.ItemGroupDataAreaId = curext();
               // inventItemGroupItem.update();
              }

                //Extended product details - Inventory
               // inventTableModule.clear();
               // inventTableModule.initValue();
               select forUpdate RecId from inventTableModule where inventTableModule.ItemId == inventTable.ItemId;
              {
                inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
              //  inventTableModule.update();
              }

                //Extended product details - Purchase
               // inventTableModule.clear();
               // inventTableModule.initValue();
              select forUpdate RecId from inventTableModule where   inventTableModule.ItemId == inventTable.ItemId;
              {
                inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
               // inventTableModule.update();
              }

                //Extended product details - Sales
               // inventTableModule.clear();
               // inventTableModule.initValue();
               select forUpdate RecId from inventTableModule where inventTableModule.ItemId == inventTable.ItemId;
              {
                inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
              //  inventTableModule.update();
              }

                //Warehouse items
                InventItemLocation::findDefault(inventTable.ItemId);

                //Supply type setup
                //inventItemSetupSupplyType.clear();
                //inventItemSetupSupplyType.initValue();
                select forUpdate RecId from inventItemSetupSupplyType where inventItemSetupSupplyType.ItemId == inventTable.ItemId;
              {
                inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
               // inventItemSetupSupplyType.update();
              }

                //Product storage dimension group
                ecoResStorageDimensionGroupProduct = EcoResStorageDimensionGroupProduct::findByProduct(ecoResProductMaster.RecId);

                if (ecoResStorageDimensionGroupProduct.RecId)
                {
                    //ecoResStorageDimensionGroupItem.clear();
                   // ecoResStorageDimensionGroupItem.initValue();
                    select forUpdate RecId from ecoResStorageDimensionGroupItem where ecoResStorageDimensionGroupItem.ItemId == inventTable.ItemId;
                    {
                    ecoResStorageDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
                   // ecoResStorageDimensionGroupItem.ItemId = inventTable.ItemId;
                    ecoResStorageDimensionGroupItem.StorageDimensionGroup   = ecoResStorageDimensionGroupProduct.StorageDimensionGroup;
                   // ecoResStorageDimensionGroupItem.update();
                    }
                }

                //Product tracking dimension group
                ecoResTrackingDimensionGroupProduct = EcoResTrackingDimensionGroupProduct::findByProduct(ecoResProductMaster.RecId);
                if (ecoResTrackingDimensionGroupProduct.RecId)
                {
                    //ecoResTrackingDimensionGroupItem.clear();
                   // ecoResTrackingDimensionGroupItem.initValue();
                   select forUpdate RecId from ecoResTrackingDimensionGroupItem where  ecoResTrackingDimensionGroupItem.ItemId == inventTable.ItemId;
                    ecoResTrackingDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
                   // ecoResTrackingDimensionGroupItem.ItemId = inventTable.ItemId;
                    ecoResTrackingDimensionGroupItem.TrackingDimensionGroup = ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup;
                   // ecoResTrackingDimensionGroupItem.update();
                }
         // }
           // inventDim.clear();
            inventDim.ConfigId = description;/*ConfigId*/
            inventDim = InventDim::findOrCreate(inventDim);

            //Released product variant
           // inventDimCombination.clear();
           // inventDimCombination.initValue();
            inventDimCombination.DistinctProductVariant = inventDimCombination::findByDistinctProductVariant(ecoResDistinctProductVariant.RecId).DistinctProductVariant;
            select forupdate RecId from inventDimCombination where inventDimCombination.ItemId == inventTable.ItemId;
          {
            inventDimCombination.InventDimId = inventDim.InventDimId;
            //inventDimCombination.update();
          }
        }
    //}
    catch
    {
        error("Error!");
        return;
    }
    info("Import completed !");
}

Use of Memo field in full text index in ax 2012

static void FullTextIndex(Args _args)
{
    TableName tableName;
    Query query;
    QueryBuildDataSource queryBDSource;
    QueryBuildRange queryBRange;
    QueryRun queryRun;
    query = new Query();
    queryBDSource = query.addDataSource(tableNum(TableName ));
    queryBRange = queryBDSource.addRange(fieldnum(TableName ,MemoFieldName),1,QueryRangeType::FullText);
    queryBRange.value("Company");
    queryRun = new QueryRun(query);
    while (queryRun.next())
    {
        tableName = queryRun.get(tableNum(TableName ));
        info(tableName.MemoFieldName);
    }
}

Send Email from Outlook in AX

static void DemoOutlookEmail(Args _args)
{
    SmmOutlookEmail smmOutlookEmail = new SmmOutlookEmail();
    ;
    if (smmOutlookEmail.createMailItem())
    {
        smmOutlookEmail.addEMailRecipient('abc@xyz.in');
        smmOutlookEmail.addSubject("Test");
        smmOutlookEmail.isHTML(true);
        smmOutlookEmail.addBodyText('Test');
        smmOutlookEmail.sendEMail(smmSaveCopyofEmail::No);
    }
}

Import And Release Full Description of item from excel in ax 2012

static void NewImport(Args _args)
{
    SysExcelApplication                       xlsApplication;
    SysExcelWorkBooks                         xlsWorkBookCollection;
    SysExcelWorkBook                          xlsWorkBook;
    SysExcelWorksheets                        xlsWorkSheetCollection;
    SysExcelWorksheet                         xlsWorkSheet;
    SysExcelRange                             xlsRange;
    SysExcelCells                             Cells;
    SysExcelCell                              RCell;
    CommaIO                                   inFile;
    int                                       nRow,i;
    DialogField                               dialogPath;
    Dialog                                    dialog;
    Filename                                  filename;

    EcoResProductMaster                       ecoResProductMaster;
    EcoResProductIdentifier                   ecoResProductIdentifier;
    EcoResProductDimensionGroupProduct        ecoResProductDimensionGroupProduct;
    EcoResProductMasterModelingPolicy         ecoResProductMasterModelingPolicy;
    EcoResStorageDimensionGroupProduct        ecoResStorageDimensionGroupProduct;
    EcoResTrackingDimensionGroupProduct       ecoResTrackingDimensionGroupProduct;
    EcoResConfiguration                       ecoResConfiguration;
    EcoResProductMasterConfiguration          ecoResProductMasterConfiguration;
    EcoResDistinctProductVariant              ecoResDistinctProductVariant;
    EcoResProductVariantConfiguration         ecoResProductVariantConfiguration;

    InventTable                               inventTable;
    InventTableModule                         inventTableModule;
    InventItemSetupSupplyType                 inventItemSetupSupplyType;

    EcoResStorageDimensionGroupItem           ecoResStorageDimensionGroupItem;
    EcoResTrackingDimensionGroupItem          ecoResTrackingDimensionGroupItem;

    InventModelGroupItem                      inventModelGroupItem;
    InventItemGroupItem                       inventItemGroupItem;

    InventDim                                 inventDim;
    InventDimCombination                      inventDimCombination;

    PdsCWProduct                              pdsCWProduct;
    EcoResProductDisplayProductNumber         ecoResProductDisplayProductNumber;
    EcoResProductSearchName                   ecoResProductSearchName;
    EcoResProductType                         ecoResProductType;
    EcoResDistinctProduct                     ecoResDistinctProduct;

    //Traslation
    EcoResProductTranslation                  ecoResProductTranslation;
    LanguageId                                LanguageId;
    EcoResProductName                         ecoResProductName;
    EcoResDescription                         ecoResDescription;
    //EcoResProductDimensionGroup
    EcoResProductDimensionGroup               ecoResProductDimensionGroup;
    EcoResProductDimensionGroupName           ecoResProductDimensionGroupName;
    Description                               description;
    //EcoResStorageDimensionGroup
    EcoResStorageDimensionGroup               ecoResStorageDimensionGroup;
    EcoResStorageDimensionGroupName           ecoResStorageDimensionGroupName;
    //Description                               description;
    //EcoResTrackingDimensionGroup
    EcoResTrackingDimensionGroup              ecoResTrackingDimensionGroup;
    EcoResTrackingDimensionGroupName          ecoResTrackingDimensionGroupName;
    //EcoResProductMaster
    RetailColorGroupId                        retailColorGroupId;
    RetailSizeGroupId                         retailSizeGroupId;
    RetailStyleGroupId                        retailStyleGroupId;
    EcoResVariantConfigurationTechnologyType  ecoResVariantConfigurationTechnologyType;
    ;
    dialog = new Dialog("Import");
    dialogPath = dialog.addField(extendedTypeStr(Filenameopen), "File Name");
    dialog.run();
    if (dialog.run())
    {
        filename = (dialogPath.value());
    }
    inFile = new CommaIO (filename, 'R');
    if (!inFile || infile.status() != IO_Status::Ok )
    {
        throw error (strfmt("@SYS19312",filename));
    }
    try
    {
        xlsApplication          = SysExcelApplication::construct();
        xlsWorkBookCollection   = xlsApplication.workbooks();
        xlsWorkBookCollection.open(filename);
        xlsWorkSheetCollection  = xlsApplication.worksheets();
        xlsWorkSheet            = xlsWorkSheetCollection.itemFromNum(1);
        Cells                   = xlsWorkSheet.Cells();
        nRow = 2;
        RCell = Cells.Item(nRow, 1);
        while (RCell.value().bStr() != "")
        {
            ecoResProductDisplayProductNumber = RCell.value().bStr();
            RCell  = Cells.item(nRow,2);
            pdsCWProduct = any2enum( RCell.value().bStr());
            RCell  = Cells.item(nRow,3);
            ecoResProductType =str2enum(ecoresproducttype, RCell.value().bStr());
            RCell  = Cells.item(nRow,4);
            ecoResProductSearchName   = RCell.value().bStr();
            RCell  = Cells.item(nRow,5);
            ecoResProductName   = RCell.value().bStr();
            RCell  = Cells.item(nRow,6);
            ecoResDescription   = RCell.value().bStr();
            RCell  = Cells.item(nRow,7);
            LanguageId   = RCell.value().bStr();
            RCell  = Cells.item(nRow,8);
            ecoResProductDimensionGroupName   = RCell.value().bStr();
            RCell  = Cells.item(nRow,9);
            description = RCell.value().bStr();
            RCell  = Cells.item(nRow,10);
            ecoResStorageDimensionGroupName = RCell.value().bStr();
            RCell  = Cells.item(nRow,11);
            description = RCell.value().bStr();
            RCell  = Cells.item(nRow,12);
            ecoResTrackingDimensionGroupName = RCell.value().bStr();
            RCell  = Cells.item(nRow,13);
            description = RCell.value().bStr();
            RCell  = Cells.item(nRow,14);
            retailColorGroupId = RCell.value().bStr();
            RCell  = Cells.item(nRow,15);
            retailSizeGroupId = RCell.value().bStr();
            RCell  = Cells.item(nRow,16);
            retailStyleGroupId = RCell.value().bStr();
            RCell  = Cells.item(nRow,17);
            ecoResVariantConfigurationTechnologyType = str2enum(ecoResVariantConfigurationTechnologyType, RCell.value().bStr());
            nRow++;
            RCell = Cells.Item(nRow, 1);
        }
        xlsApplication.quit ();
        xlsApplication.finalize ();
        info("Import completed");
    }
    catch( Exception::Error)
    {
        //Close Excel.
        xlsApplication.quit ();
        xlsApplication.finalize ();
        ttsabort;
        info("Unable to process the excel import ");
    }

    try
    {
        //ProductMaster
        ecoResProductMaster.clear();
        ecoResProductMaster.initValue();
        ecoResProductMaster.ProductType = ecoResProductType;
        ecoResProductMaster.DisplayProductNumber = ecoResProductDisplayProductNumber;
        ecoResProductMaster.SearchName = ecoResProductSearchName;
        ecoResProductMaster.VariantConfigurationTechnology = ecoResVariantConfigurationTechnologyType;
        ecoResProductMaster.RetailColorGroupId = retailColorGroupId;
        ecoResProductMaster.RetailSizeGroupId = retailSizeGroupId;
        ecoResProductMaster.RetailStyleGroupId = retailStyleGroupId;
        if (ecoResProductMaster.validateWrite())
        {
            ecoResProductMaster.insert();
            ecoResProductIdentifier.clear();
            ecoResProductIdentifier.initValue();
            ecoResProductIdentifier.ProductNumber = ecoResProductDisplayProductNumber;
            ecoResProductIdentifier.Product = ecoResProductMaster.RecId;
            ecoResProductIdentifier.insert();

            //Product dimension group
            ecoResProductDimensionGroupProduct.clear();
            ecoResProductDimensionGroupProduct.initValue();
            ecoResProductDimensionGroupProduct.initFromProduct(ecoResProductMaster);
            ecoResProductDimensionGroupProduct.ProductDimensionGroup = EcoResProductDimensionGroup::findByDimensionGroupName(ecoResProductDimensionGroupName).RecId;
            if (ecoResProductDimensionGroupProduct.validateWrite())
            {
                ecoResProductDimensionGroupProduct.insert();
            }

            //Storage dimension group
            ecoResStorageDimensionGroupProduct.clear();
            ecoResStorageDimensionGroupProduct.initValue();
            ecoResStorageDimensionGroupProduct.Product = ecoResProductMaster.RecId;
            ecoResStorageDimensionGroupProduct.StorageDimensionGroup = EcoResStorageDimensionGroup::findByDimensionGroupName(ecoResStorageDimensionGroupName).RecId;
            if (ecoResStorageDimensionGroupProduct.validateWrite())
            {
                ecoResStorageDimensionGroupProduct.insert();
            }

            //Tracking dimension group
            ecoResTrackingDimensionGroupProduct.clear();
            ecoResTrackingDimensionGroupProduct.initValue();
            ecoResTrackingDimensionGroupProduct.Product = ecoResProductMaster.RecId;
            ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup = EcoResTrackingDimensionGroup::findByDimensionGroupName(ecoResTrackingDimensionGroupName).RecId;
            if (ecoResTrackingDimensionGroupProduct.validateWrite())
            {
                ecoResTrackingDimensionGroupProduct.insert();
            }

            //Product modeling policy
            ecoResProductMasterModelingPolicy.clear();
            ecoResProductMasterModelingPolicy.initValue();
            ecoResProductMasterModelingPolicy.ProductMaster = ecoResProductMaster.RecId;
            if (ecoResProductMasterModelingPolicy.validateWrite())
            {
                ecoResProductMasterModelingPolicy.insert();
            }

            //Product translation
            EcoResProductTranslation::createOrUpdateTranslation(ecoResProductMaster.RecId, ecoResProductName, ecoResDescription);

            //Configuration
            ecoResConfiguration = EcoResConfiguration::findByName(description);
            if (!ecoResConfiguration)
            {
                ecoResConfiguration.clear();
                ecoResConfiguration.initValue();
                ecoResConfiguration.Name = description;
                ecoResConfiguration.insert();
            }

            //Configuration assigned to product master
            ecoResProductMasterConfiguration.clear();
            ecoResProductMasterConfiguration.initValue();
            ecoResProductMasterConfiguration.Configuration = ecoResConfiguration.RecId;
            ecoResProductMasterConfiguration.Description = description;
            ecoResProductMasterConfiguration.ConfigProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, ConfigId));
            ecoResProductMasterConfiguration.ConfigProductMaster = ecoResProductMaster.RecId;
            ecoResProductMasterConfiguration.insert();

            //Product variant
            ecoResDistinctProductVariant.clear();
            ecoResDistinctProductVariant.initValue();
            ecoResDistinctProductVariant.DisplayProductNumber = EcoResProductNumberBuilderVariant::buildFromProductNumberAndDimensions(
            ecoResProductMaster.productNumber(),
            EcoResProductVariantDimValue::getDimensionValuesContainer(description, "", ""));
            ecoResDistinctProductVariant.SearchName = ecoResProductMaster.SearchName + ecoResProductSearchName/*ConfigId*/;
            ecoResDistinctProductVariant.ProductType = ecoResProductMaster.ProductType;
            ecoResDistinctProductVariant.ProductMaster = ecoResProductMaster.RecId;
            ecoResDistinctProductVariant.insert();

            //Product variant configuration
            ecoResProductVariantConfiguration.clear();
            ecoResProductVariantConfiguration.initValue();
            ecoResProductVariantConfiguration.initFromDistinctProductVariant(ecoResDistinctProductVariant);
            ecoResProductVariantConfiguration.ProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, ConfigId));
            ecoResProductVariantConfiguration.Configuration = ecoResConfiguration.RecId;
            ecoResProductVariantConfiguration.insert();

            //Product variant translation
            EcoResProductTranslation::createOrUpdateTranslation(ecoResDistinctProductVariant.RecId, ecoResProductName, ecoResDescription);

            //Released product
            inventTable.clear();
            inventTable.initValue();
            inventTable.initFromEcoResProduct(ecoResProductMaster);
            inventTable.ItemId = ecoResProductDisplayProductNumber;
            inventTable.NameAlias = ecoResProductSearchName;
            if (inventTable.validateWrite())
            {
                inventTable.insert();
                //Inventory model group
                inventModelGroupItem.clear();
                inventModelGroupItem.initValue();
                inventModelGroupItem.ItemDataAreaId = inventTable.dataAreaId;
                inventModelGroupItem.ItemId = inventTable.ItemId;
                inventModelGroupItem.ModelGroupId = "FIFO";
                inventModelGroupItem.ModelGroupDataAreaId = curext();
                inventModelGroupItem.insert();

                //Item group
                inventItemGroupItem.clear();
                inventItemGroupItem.initValue();
                inventItemGroupItem.ItemDataAreaId = inventTable.dataAreaId;
                inventItemGroupItem.ItemId = inventTable.ItemId;
                inventItemGroupItem.ItemGroupId = "Parts";
                inventItemGroupItem.ItemGroupDataAreaId = curext();
                inventItemGroupItem.insert();

                //Extended product details - Inventory
                inventTableModule.clear();
                inventTableModule.initValue();
                inventTableModule.ItemId = inventTable.ItemId;
                inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
                inventTableModule.insert();

                //Extended product details - Purchase
                inventTableModule.clear();
                inventTableModule.initValue();
                inventTableModule.ItemId = inventTable.ItemId;
                inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
                inventTableModule.insert();

                //Extended product details - Sales
                inventTableModule.clear();
                inventTableModule.initValue();
                inventTableModule.ItemId = inventTable.ItemId;
                inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
                inventTableModule.insert();

                //Warehouse items
                InventItemLocation::createDefault(inventTable.ItemId);

                //Supply type setup
                inventItemSetupSupplyType.clear();
                inventItemSetupSupplyType.initValue();
                inventItemSetupSupplyType.ItemId = inventTable.ItemId;
                inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
                inventItemSetupSupplyType.insert();

                //Product storage dimension group
                ecoResStorageDimensionGroupProduct = EcoResStorageDimensionGroupProduct::findByProduct(ecoResProductMaster.RecId);

                if (ecoResStorageDimensionGroupProduct.RecId)
                {
                    ecoResStorageDimensionGroupItem.clear();
                    ecoResStorageDimensionGroupItem.initValue();
                    ecoResStorageDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
                    ecoResStorageDimensionGroupItem.ItemId = inventTable.ItemId;
                    ecoResStorageDimensionGroupItem.StorageDimensionGroup   = ecoResStorageDimensionGroupProduct.StorageDimensionGroup;
                    ecoResStorageDimensionGroupItem.insert();
                }

                //Product tracking dimension group
                ecoResTrackingDimensionGroupProduct = EcoResTrackingDimensionGroupProduct::findByProduct(ecoResProductMaster.RecId);
                if (ecoResTrackingDimensionGroupProduct.RecId)
                {
                    ecoResTrackingDimensionGroupItem.clear();
                    ecoResTrackingDimensionGroupItem.initValue();
                    ecoResTrackingDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
                    ecoResTrackingDimensionGroupItem.ItemId = inventTable.ItemId;
                    ecoResTrackingDimensionGroupItem.TrackingDimensionGroup = ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup;
                    ecoResTrackingDimensionGroupItem.insert();
                }
            }
            inventDim.clear();
            inventDim.ConfigId = description;/*ConfigId*/
            inventDim = InventDim::findOrCreate(inventDim);

            //Released product variant
            inventDimCombination.clear();
            inventDimCombination.initValue();
            inventDimCombination.DistinctProductVariant = ecoResDistinctProductVariant.RecId;
            inventDimCombination.ItemId = inventTable.ItemId;
            inventDimCombination.InventDimId = inventDim.InventDimId;
            inventDimCombination.insert();
        }
    }
    catch
    {
        error("Error!");
        return;
    }
    info("Release Done!");
}