Wednesday, October 24, 2012

Print Main Menu

Question: How can i print all elements of a main menu.

Answer: Use the following job, 


static void menuPrint(Args _args)
{

    SysDictMenu menu;
    SysExcelWorksheetHelper worksheetHelper;
    SysExcelHelper sysExcelHelper;
    SysExcelWorksheet worksheet;
    str menuToPrint;
    str worksheetName;
    int currentRow = 1;
    str fileName;
    str path;

    void reportLevel(SysDictMenu _sysDictMenu)
    {

        SysMenuEnumerator enumerator;

        if(_sysDictMenu.isMenuReference() || _sysDictMenu.isMenu())
        {
            path += _sysDictMenu.label() + "//";
            enumerator = _sysDictMenu.getEnumerator();
            while (enumerator.moveNext())
            {
                reportLevel(enumerator.current());
            }
        }
        else
        {   currentRow ++;
            worksheetHelper.setCellValue(2, currentRow, _sysDictMenu.label());
            path = "";
        }
    }

    ;

    sysExcelHelper = SysExcelHelper::construct();
    sysExcelHelper.initialize();

    menuToPrint = 'Roster';
    worksheetName = menuToPrint;
    worksheet = sysExcelHelper.addWorksheet(worksheetName);
    worksheetHelper = SysExcelWorksheetHelper::construct(worksheet);
    // Populate the header row with the appropriate field labels and format the columns
    worksheetHelper.addColumn(1, "Path", Types::String);
    worksheetHelper.addColumn(2, "Item", Types::String);
    worksheetHelper.addColumn(3, "Status", Types::String);
    worksheetHelper.addColumn(4, "Assigned To", Types::String);
    worksheetHelper.addColumn(5, "Notes", Types::String);
    reportLevel(SysDictMenu::newMenuName(MenuStr(Roster)));
    worksheetHelper.autoFitColumns();
    worksheetHelper.formatWorksheetTableStyle(sysExcelHelper.getOfficeVersion());


    // Generate the file using the current UTC date time (without the ‘:’ character)
    // since it is not allowed for file names.
    fileName =  "C:\\Windows\\Temp\\ExportToExcel.xlsx";

    sysExcelHelper.save(filename);
    sysExcelHelper.launchExcel();
}

Tuesday, August 28, 2012

Read / Write Files from document handling

Question:
How can you read / writes files from document handling?

Answer:

void fromFolderToDB(FilePath _path)
{
System.IO.DirectoryInfo         dir = new
System.IO.DirectoryInfo(_path);
System.IO.FileInfo[]            files;
System.IO.FileInfo              curFile;
System.Collections.IEnumerator  enumerator;
BinData                         binData;
DocuValue                       docuValue;
;
files = dir.GetFiles(_path);
enumerator = files.GetEnumerator();
while (enumerator.MoveNext())
{
curFile = enumerator.get_Current();
docuValue.clear();
binData.loadFile(curFile.get_FullName());   // get file content
docuValue.File      = binData.getData();
docuValue.FileName  = curFile.get_Name();
docuValue.insert(); // insert into DB
}
}
void fromDBToFolder(FilePath _path)
{
BinData                         binData;
DocuValue                       docuValue;
;
while select docuValue // load From DB
{
binData.setData(docuValue.File);
binData.saveFile(docuValue.FileName); // insert into file system
}
}
Make attention to CodeAccessPermission when reading/writing to file system
and when using CLR inside X++

Monday, August 13, 2012

CAL License or Server License for SQL Server in AX Environment

Question
Should we use CAL based licensing or server based licensing for SQL Server in AX Environment?

Answer
Please read the link from here. 

Wednesday, August 1, 2012

Matching Invoices to Portions of a Packing Slip

Question
Is there any way to find out invoices corresponding to individual packing slips


Answer
There is a link between InventTrans, CustInvoiceJourn and CustPackingSlipJour. This can be used to get the desired result. Also read this document.


Links
http://www.microsoft.com/en-us/download/details.aspx?id=23769

Thursday, July 26, 2012

Sending email through outlook in Dynamics AX

Question:
How can i send an email in AX through outlook?

Answer:

static void OutlookEmail(Args _args)
{
    SmmOutlookEmail smmOutlookEmail = new SmmOutlookEmail();

    ;
    if (smmOutlookEmail.createMailItem())
    {
        smmOutlookEmail.addEMailRecipient('asamad@moorestephens.com.au');
        smmOutlookEmail.addSubject("Test");
        smmOutlookEmail.isHTML(true);
        smmOutlookEmail.addBodyText('Test');
        smmOutlookEmail.sendEMail(smmSaveCopyofEmail::No);
    }
}

Thursday, July 19, 2012

AxUpdatePortal not working with SharePoint 2010

Question:
When trying to deploy files using AxUpdatePortal utility in a SharePoint 2010 environment, the utility is not working at all.

Answer:
Make sure you have completed all the steps mentioned in the KB 2278963.