September 03, 2013

How to create a link in info log

Issue:  I come across a user requirement , that user need a link on info log for go to main table.

Scenario:  For example
If user create a Purchase Order from "Release approved purchase requisition", than system create a PO and in info log it show the PO number. When user double click on this PO number it redirect to PO form.
User need this same functionality for a customized process.

Possible Solution:
Use following code for Info log

Info(strfmt('Journal_Number : %1 \n Voucher_Number : %2 ', _journalnum, _voucher),"",SysInfoAction_TableField::newBuffer(ledgerJournaltable));

-Harry

X++ Code to Find and Remove The Duplicate Objects in AOT

 X++ Code to Find and Remove The Duplicate Objects in AOT

Please Note following cautions before proceeding....

BackUp of Application:-

Setup a new instance and Copied the var.aod files (Or other layer where your customization exist) from production instance and restored the DB with live DB.
DO NOT DO THIS DIRECT ON LIVE SERVERS

Use the following code to delete the identical copy.

static void theAxapta_FindAndDeleteIdenticalObjects(Args _args)
{
SysTreeNode comparable1, comparable2;
TreeNode curLevelTreeNode, upperLevelTreeNode;
UtilIdElements utilElements, joinUtilElements;
;
while select UtilElements
where UtilElements.utilLevel == UtilEntryLevel::var &&
(
UtilElements.recordType == UtilElementType::Form ||
Utilelements.recordType == UtilElementType::Report ||
Utilelements.recordType == UtilElementType::Table ||
Utilelements.recordType == UtilElementType::Class ||
Utilelements.recordType == UtilElementType::Enum ||
Utilelements.recordType == UtilElementType::ExtendedType
)
{
//Should use join if for a normal table, but not applicable for UtilElements
//Performance hit if use exists join
select firstonly recid from joinUtilElements
where joinUtilElements.utilLevel != UtilElements.utilLevel &&
joinUtilElements.name == UtilElements.name &&
joinUtilElements.recordType == UtilElements.recordType;
if (joinUtilElements.RecId)
{

curLevelTreeNode = SysTreeNode::findNodeInLayer(UtilElements.recordType, UtilElements.name, UtilElements.parentId, UtilElements.utilLevel);
upperLevelTreeNode = SysTreeNode::getLayeredNode(curLevelTreenode, 1);
comparable1 = SysTreeNode::newTreeNode(curLevelTreeNode);
comparable2 = SysTreeNode::newTreeNode(upperLevelTreeNode);
if (SysCompare::silentCompare(comparable1, comparable2))
{
info(strFmt("Element name: %1, Element type: %2", UtilElements.name, enum2str(UtilElements.recordType)));
//Remove the node
curLevelTreeNode.AOTdelete();
}
}
}
}


-Harry

August 30, 2013

Print PDF files from AX X++ code

Print External PDF file from AX 

This job illustrates how we can print an external PDF file to a printer chosen in AX through X++ code. Here a code sample (X++ job) to do this.

static void theAxapta_pdfprint(Args _args)
{ 
    PrintJobSettings    printJobSettings = new PrintJobSettings(); 
    Dialog              dialog = new Dialog(); 
    DialogField         dialogFileName; 
    str                 adobeExe; 
    str                 adobeParm; 
;
    dialogFilename  = dialog.addField(typeid(FilenameOpen));

    if (dialog.run()) 
    {     
        printJobSettings.printerSettings('SysPrintForm');     
        adobeExe = WinAPI::findExecutable(dialogFileName.value());
       
        adobeParm = strFmt(' /t "%1" "%2" "%3" "%4"',
                           dialogFileName.value(),
                           printJobSettings.printerPrinterName(),
                           printJobSettings.printerDriverName(),
                           printJobSettings.printerPortName());

        winAPI::shellExecute(adobeExe,  adobeParm); 
    }
}

-Harry

Dynamics AX 2012 Certification Exams Details- Part I

Dynamics AX 2012 Certification Exams Details- Part I



Exam title Exam number
Microsoft Dynamics AX 2012 Trade and Logistics MB6-870
Microsoft Dynamics AX 2012 Financials MB6-871
Microsoft Dynamics AX 2012 Development Introduction MB6-869
Microsoft Dynamics AX 2012 Installation and Configuration MB6-872
Microsoft Dynamics AX 2012 Process Manufacturing Production and Logistics MB6-886
Microsoft Dynamics AX 2012 Lean Manufacturing MB6-884
Microsoft Dynamics AX 2012 Public Sector MB6-885
Microsoft Dynamics AX 2012 Service Management MB6-889