Refresh Listpage from Child form AX 2012

You often open a dialog or drop dialog when you are working with another form. As a result, you might want to refresh the parent form after you finish the action on the dialog or drop dialog form. However, not every dialog form requires that you update the calling form. Typically, you refresh the parent form when the information that you provide in the dialog form appears on that form.

To refresh a parent form,you must write your code in Child form by Override method CloseOk and write the below code.

public void closeOk()
{
    #Task
    FormRun formRun;
    
    super();
    
    // Get an instance of the calling form.
    formRun = element.args().caller();
    
    // If the caller is a form, refresh that form.
    if(formRun)
    {
        formRun.task(#taskF5);
    }
}

100% working : Fatal exception performing AXRDCE transformation step. The report cannot be rendered. Please contact your system administrator.

Hello Guys,

Today I came with new issue in AX Report.

Few days back my report was working fine.

But today it showed me something weird information while opening the report.

Fatal exception performing AXRDCE transformation step. The report cannot be rendered. Please contact your system administrator. Continue reading

Cannot create a record in Table () , The record already exists.

Sometime you tried to insert some record in the table, if the system shows Cannot create a record in Table () , The record already exists. Generally we know that, this issues is caused due to Duplicate value. But here is the trick, so even i have checked the Index values which is allow duplicate yes. But still why this issue.. Basically we know that dynamics AX has invisible Index in every Table which is Recid, so this Recid is generating from SystemSequences Table( field nextval). So this SystemSequences  table contains every table Id and its next recid value in nextval field, so if it has a value with an already issued record id, you can increase the number.  To access this SystemSequences table you have to use SQL Management studio, Better it’s recommended to stay away from this table.

 

Hope you enjoyed.

Drillthrough Report in SSRS

Hi Guys, Have a Good Day!. Hope you are doing Good.

Today I’m going to share you how to developDrillthrough report in SSRS.

Confused ?

Don’t worry. Let me explain in short manner. Drillthrough report is a report that user can opens by clicking a link within another report. For example, We are listing All the Vendors and want to iterate vendors to all of his Purchase Orders and to their Purchase Order Details.

CONCEPT1

For more Details DrillThrough Reports in SSRS

We are going to illustrates the following tasks:
• Creating a Report Model project. 
• Creating reports 
• Vendor list 
• Purchase order list 
• Purchase order details 
• Providing drill-through action under designs 
• Saving the report to AOT and deploying it to the Report Server.
 Continue reading 

Move File from One Folder to Another Folder using X++

Hi Guys . I hope you are doing Good.

Today i’m going to share you that , how to move a File from One Folder to another folder using X++.

Here we can achieve this with the Help of WINAPI(Windows Application Programming Interface). Even though we can do Copy a file, delete a file, Create Directory, getting the file Size, etc. Refer more Details WINAPI

static void MoveFilesFromFoldertoAnotherFolder(Args _args)
{
 FilenameOpen fileNameOpen;
 DialogField dialogFileName;
 Dialog dialog;
 Filename filePath;
 Filename fileName;
 Filename fileType;
 FileName DestinationPath;
 #File
 
 ;
DestinationPath = @'C:\Users\saadullah\Desktop\Dest\'; // Define your Destination Path
 dialog = new Dialog("Move Files");
// AX 2009
 dialogFilename = dialog.addField(typeId(FileNameOpen));
// AX 2012
 // dialogFileName = dialog.addField(extendedTypeStr(FileNameOpen));
dialog.filenameLookupFilter([#AllFilesType]);
 dialog.filenameLookupTitle("Select File");
 dialog.caption("Move File");
 dialogFilename.value(fileName);
if(!dialog.run())
 return;
filenameOpen = dialogFilename.value();
 [filePath, fileName, fileType] = fileNameSplit(fileNameOpen);
// MoveFile - The Original File won't be available once it's moved into destination path
WinAPI::moveFile(fileNameOpen, DestinationPath+FileName+FileType);
// CopyFile - The Original File will be available even if it's moved into destination path
 //WinAPI::copyFile(fileNameOpen, DestinationPath+FileName+FileType);
// DeleteFile - Delete the Selected File
 //WinAPI::deleteFile(fileNameOpen);
 
 // If u need to Use this in Form Take look in AOT > Forms > Tutorial_Form_File
}

Collecting AOT object Properties Details in to Excel

One of the user posted in DUG that he required the list of all Classes and its properties from AOT to extract into Excel..  So, here is my solution…..

static void Export_Classes_propertied(Args _args)
{
    SysExcelApplication xlsApplication;
    SysExcelWorkBooks xlsWorkBookCollection;
    SysExcelWorkBook xlsWorkBook;
    SysExcelWorkSheets xlsWorkSheetCollection;
    SysExcelWorkSheet xlsWorkSheet;
    SysExcelRange xlsRange;
    int row = 1;
    str fileName;
    TreeNode classesNode = TreeNode::findNode(@'\Classes');
    TreeNodeIterator iterator = ClassesNode.AOTiterator();
    TreeNode classNode = iterator.next();
    ClassName   className;
    UtilElements utilElements;
    System.DateTime CreatedSysDate, ModifiedDate;
    utcdatetime UtcCreatedDate, UtcModifiedDate;
    str StrCreatedDate, strModifiedDate;
    ;
    //Filename
    fileName = "C:\\Users\\saadullah\\Desktop\\Class.xlsx";  // Define your Excel Path


    //Initialize Excel instance
    xlsApplication = SysExcelApplication::construct();
    //Open Excel document
    //xlsApplication.visible(true);
    //Create Excel WorkBook and WorkSheet
    xlsWorkBookCollection = xlsApplication.workbooks();
    xlsWorkBook = xlsWorkBookCollection.add();
    xlsWorkSheetCollection = xlsWorkBook.worksheets();
    xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);

    //Excel columns captions
    xlsWorkSheet.cells().item(row,1).value("ID");
    xlsWorkSheet.cells().item(row,2).value("Name");
    xlsWorkSheet.cells().item(row,3).value("Extends");
    xlsWorkSheet.cells().item(row,4).value("RunOn");
    xlsWorkSheet.cells().item(row,5).value("CreatedBy");
    xlsWorkSheet.cells().item(row,6).value("CreatedDateTime");
    xlsWorkSheet.cells().item(row,7).value("ChangedBy");
    xlsWorkSheet.cells().item(row,8).value("ChangedDateTime");
   
    row++;

    while (classNode)
    {
        className = classNode.treeNodeName();
        classNode.AOTgetProperties(true);
        select utilElements
            where utilElements.RecordType == UtilElementType::Class
            && utilElements.Name == className;
        UtcCreatedDate = utilElements.createdDateTime;
        CreatedSysDate = Global::utcDateTime2SystemDateTime(UtcCreatedDate);
        UtcCreatedDate = Global::CLRSystemDateTime2UtcDateTime(CreatedSysDate);
        StrCreatedDate = DateTimeUtil::toStr(UtcCreatedDate);
        UtcModifiedDate = utilElements.modifiedDateTime;
        ModifiedDate = Global::utcDateTime2SystemDateTime(UtcModifiedDate);
        UtcModifiedDate = Global::CLRSystemDateTime2UtcDateTime(ModifiedDate);
        strModifiedDate = DateTimeUtil::toStr(UtcCreatedDate);

        xlsWorkSheet.cells().item(row,1).value(classNode.applObjectId());
        xlsWorkSheet.cells().item(row,2).value(classNode.AOTgetProperty('Name'));
        xlsWorkSheet.cells().item(row,3).value(classNode.AOTgetProperty('Extends'));
        xlsWorkSheet.cells().item(row,4).value(classNode.AOTgetProperty('RunOn'));
        xlsWorkSheet.cells().item(row,5).value(utilElements.createdBy);
        xlsWorkSheet.cells().item(row,6).value(StrCreatedDate);
        xlsWorkSheet.cells().item(row,7).value(utilElements.modifiedBy);
        xlsWorkSheet.cells().item(row,8).value(strModifiedDate);
        classNode = iterator.next();
        
        row++;
    }

    //Check whether the document already exists
    if(WinApi::fileExists(fileName))
    WinApi::deleteFile(fileName);

    //Save Excel document
    xlsWorkbook.saveAs(fileName);
    xlsWorkbook.comObject().save();
    //Open Excel document
    xlsApplication.visible(true);

    //Close Excel
    //xlsApplication.quit();
    //xlsApplication.finalize();
}

Period is not Open

Hi Guys..

I have started with SCM , i have created one PO then im trying to do Packing Slip by filling the Packing Slip #, But it showing Period is not Open on my given Paking Slip Date.

the reason behind the error is there is no Fiscal Period for my packing Slip date.

So i have create Period in General Ledger->Setup->Periods->Periods

Problem solved….

Import CSV files

As you have seen the Exporting Complete Table Record into CSV in the last post. Same way here i have written Code for Importing CSV into Table

static void Import_CSV(Args _args)
{
common TableBuffer;
DictTable dictTable = new DictTable(tableNum(TableName)); // Define Table Name
str TableName = dictTable.name();
DictField dictField;
int i;
CommaIo file;
container line;
str path = 'C:\\Users\\saadullah\\Documents\\'+TableName+'.csv'; // Directory Path
#define.filename(path)
#File
file = new CommaIo(#filename, #io_read);
if (!file || file.status() != IO_Status::Ok)
 {
 throw error("File cannot be opened.");
 }
TableBuffer = dictTable.makeRecord();
while (file.status() == IO_Status::Ok)
 {
 line = file.read(); // Selecting File values line by line as assigning to Container
 if (line != conNull())
 {
 // Looping the Table Field
 // we have Defined - 15 from the Counting of Fields 
 // we do not Require 15 System Field such as RecId, RecVersion, Created By, Created Datetime, Modified By, etc...
 for( i =1; i <= dictTable.fieldCnt() -15; i++)
 {
 // Selecting the Fields
 dictField = new DictField(dictTable.id(), dictTable.fieldCnt2Id(i));
 // Assigning the Container values to the Selected Table Field
 TableBuffer.(dictField.id()) = conpeek(line, i);
 }
 // Inserting Record 
 TableBuffer.doInsert();
 }
 }
}

Export CSV file

Hi Guys,.

Today i’m going to share one of the easiest way to Export and Import the Data without Microsoft Office Excel.
Its Comma Separated Value (CSV). The main Objective of CSV is storing the table record in the CSV file. even though i have found it from CookBook. But i have modified that coding for General Purpose in any table we can easily Export and Import.
Here i have written my Job for Exporting Complete data of any defined Table into CSV..

static void ExportCSV(Args _args)
 {
 common TableBuffer;
 DictTable dictTable = new DictTable(tableNum(TableName)); // Define Table Name
 str TableName = dictTable.name();
 DictField dictField;
 int i;
 CommaIo file;
 container line;
 str path = 'C:\\Users\\saadullah\\Documents\\'+TableName+'.csv'; // Directory Path
 #define.filename(path)
 #File
file = new CommaIo(#filename, #io_write);
if (!file || file.status() != IO_Status::Ok)
 {
 throw error("File cannot be opened.");
 }
TableBuffer = dictTable.makeRecord();
// Select the Entire Table
 while select TableBuffer
 {
 // Looping the Table Field
 // we have Defined - 15 from the Counting of Fields
 // we do not Require 15 System Field such as RecId, RecVersion, Created By, Created Datetime, Modified By, etc...
 for( i =1; i <= dictTable.fieldCnt() -15; i++)
 {
 // Selecting the Fields
 dictField = new DictField(dictTable.id(), dictTable.fieldCnt2Id(i));
// Adding the Selected Field values in Container
 line += [ TableBuffer.(dictField.id()) ];
}
 // Wrting the Selected Container Expression in File
 file.writeExp(line);
// we have to store the Next Records , so we are making Container to Null
 line = ConNull();
 }
info(strfmt("File Successfully Created in %1", #filename));
}

Enterprise Portal Development

This video is a developer-oriented, deep-dive technical session about Enterprise Portal (EP) for Microsoft Dynamics AX 2009. Developers will learn how to build and customize EP pages and user controls for lists, tasks, and wizards. The video also covers using SilverLight in EP.