Pages

January 21, 2013

AX 2012 R2 Step By Step Installation Guide

AX 2012 R2 Step By Step Installation 

As you know the much awaited AX 2012 R2 is launched. I just installed AX on my local computer, So i am just sharing some screen shots for your reference to install AX 2012.

1) Start the Setup Program.




2) Click "Microsoft Dynamics AX Components" under Install.



3) Click Next.



4) Select "I accept the license terms" *.



5) Choose Appropriate Option.



6) Processing will start.







7) Choose "Add or modify components".



8) Select Options to install/upgrade.



9) Review the Errors/warnings and click on "Configure" check box for the 
applicable errors. and click "Configure".



10) Click "Start" to start configuring components as per AX needs.



11) Select "Configure existing database (for upgrade scenarios)".



12) Specify your existing databases.



13) Choose models to upgrade.



14) Specify the "Temp" location for setup files.



15) Specify the SSAS details.



16) Specify credentials (we just have used the dummy account) for learning 
purpose only. Use your AD authenticated account details.



17) Specify .net BC account (if its not already there in AX)



18) Choose your Languages (en-US) in this demo.



19) Specify Data Crawler Account details.





20) SSRS Database details.



21) User Account for SSRS Access.





22) Click Install.
23) Verify the installation.


-Harry

January 12, 2013

How to pass values from form to report

How to pass values from form to report

Hi Folks,

Follow below steps to understand this, 

1. Make the report as Interactive

image

2. Create Method initFromCaller and pass the args to it.     

image

3. Set the report caption (it will appear in dialog).  

image

4. The Method initFromCaller.
Method initFromCaller  Basicllt this form will call whenever you call this menu item from FORM. 

public void initFromCaller(Args _args)
{
InventJournalTable inventJournalTable;
QueryBuildDataSource qbds;
;
if (_args.caller())
{
if (! _args.record().recId)
   throw error(strfmt("@SYS22338",funcname()));
switch (_args.dataset())
{
case tablenum(InventJournalTable):

inventJournalTable = _args.record();
if (inventJournalTable.journalType != InventJournalType::Transfer)
throw error(strfmt("@SYS23396",funcname()));

break;
default:
throw error(strfmt("@SYS23396",funcname()));
}
}

if (true || inventJournalTable.journalId)
{
qbds = element.query().dataSourceTable(tablenum(InventJournalTrans));
SysQuery::findOrCreateRange(qbds, fieldnum(InventJournalTrans, journalId)).value(inventJournalTable.journalId);
SysQuery::findOrCreateRange(qbds, fieldnum(InventJournalTrans, journalType)).value(queryValue(InventJournalType::Transfer));
}
}

Enjoy Guys......

-Harry


January 09, 2013

Sending mail from AX using .NET Framework

Sending mail from AX using .NET Framework

Sometimes happen that SysMailer class (using CDO) is not the right solution for sending mails with attachments. There is a little sample of X++ Job that is using System.Net.Mail namespace to achieve same.


static void JobNETSendMail(Args _args)
{
    System.Net.Mail.MailMessage             mailMessage;
    System.Net.Mail.Attachment              attachment;
    System.Net.Mail.AttachmentCollection    attachementCollection;
    System.Net.Mail.SmtpClient              smtpClient;
    System.Net.Mail.MailAddress             mailAddressFrom;
    System.Net.Mail.MailAddress             mailAddressTo;
    str                                     strBody;
    str                                     strSMTPServer;
    str                                     strFileName;
    FileIOPermission                        perm;
    ;

    // preparing parameters
    mailAddressFrom = new System.Net.Mail.MailAddres"test@localmail.com", "");
    mailAddressTo = new  System.Net.Mail.MailAddress("admin@localmail.com","");
    strBody = "There is a email body";
    strSMTPServer = "MailServerName";
    
    // preparing mail with body, subject, from, to.
    mailMessage = new System.Net.Mail.MailMessage(mailAddressFrom, mailAddressTo);
    mailmessage.set_Subject("There is a email subject");
    mailmessage.set_Body(strBody);
    attachementCollection = mailMessage.get_Attachments();

    strFileName = "C:\\path\\filename";
    // assert permision
    perm = new FileIOPermission(strFileName,'w');
    perm.assert();

    // attaching file to that email.
    attachment = new System.Net.Mail.Attachment(strFileName);
    attachementCollection.Add(attachment);
    smtpClient = new System.Net.Mail.SmtpClient(strSMTPServer);
    smtpClient.Send(mailmessage);
    
    // release permision
    CodeAccessPermission::revertAssert();
}

-Harry

January 07, 2013

Open any object from code editor to in AOT node(Editor script)

Open any object from code editor to in AOT node(Editor script)

I have posted a editor script method earlier that can open and browse table for code editor.using below code developer will have ease of opening any object from AX code editor to AOT node.



TO USE THIS CODE COPY AND PASTE THE METHOD IN EDITOR SCRIPT CLASS

void addIns_OpenInAOT(Editor e)
{
    #AOT
    TreeNode        treeNode;
    FreeText        selectedLine;
    str 1           curSymbol;
    int             iCopyFrom;
    int             iCopyTo;
    Set             selectedNodesSet = new Set(Types::Class);
    SetIterator     setIterator;
    Map             map;
 
    void add2Set(TreeNodePath _path)
    {
        ;
        treeNode = TreeNode::findNode(_path + #AOTRootPath + selectedLine);
        if (treeNode)
            selectedNodesSet.add(treeNode);
    }
    ;
    if (e.markMode() != MarkMode::NoMark && e.selectionStartCol() != e.selectionEndCol())
    {
        selectedLine = strLRTrim(subStr(e.currentLine(), e.selectionStartCol(), e.selectionEndCol() - e.selectionStartCol()));
    }
    else
    {
        selectedLine = e.currentLine();
        for (iCopyFrom = e.columnNo()+1; iCopyFrom >= 0; iCopyFrom--)
        {
            curSymbol = subStr(selectedLine, iCopyFrom, 1);
            if (!strAlpha(curSymbol) && curSymbol != '_')
                break;
        }
        for (iCopyTo = e.columnNo()+1; iCopyTo <= strLen(selectedLine); iCopyTo++)
        {
            curSymbol = subStr(selectedLine, iCopyTo, 1);
            if (!strAlpha(curSymbol) && curSymbol != '_')
                break;
        }
        selectedLine = (iCopyFrom < iCopyTo) ? subStr(selectedLine, iCopyFrom + 1, iCopyTo - iCopyFrom - 1) : '';
    }
 
    if (selectedLine)
    {
        add2Set(#ExtendedDataTypesPath);
        add2Set(#BaseEnumsPath);
        add2Set(#TablesPath);
        add2Set(#ClassesPath);
        add2Set(#MacrosPath);
 
        if (selectedNodesSet.elements() == 0)
        {
            add2Set(#SystemFunctionsPath);
            add2Set(#SystemTablesPath);
            add2Set(#SystemTypesPath);
            add2Set(#SystemEnumsPath);
            add2Set(#SystemClassesPath);
            add2Set(#ClassesPath + #AOTRootPath + classStr(Global));
        }
 
        if (selectedNodesSet.elements() > 0)
        {
            setIterator = new SetIterator(selectedNodesSet);
            setIterator.begin();
            if (selectedNodesSet.elements() == 1)
            {
                treeNode = setIterator.value();
            }
            else
            {
                map = new Map(Types::String, Types::String);
                while (setIterator.more())
                {
                    treeNode = setIterator.value();
                    map.insert(treeNode.treeNodePath(), treeNode.AOTparent().treeNodeName());
                    setIterator.next();
                }
                treeNode = TreeNode::findNode(pickList(map, "Location", "Select element type"));
            }
            if (treeNode && treeNode.treeNodePath() != TreeNode::rootNode().treeNodePath())
            {
                if (SysTreeNode::hasSource(treeNode))
                {
                    if (treeNode.AOTparent().treeNodePath() == #macrosPath && subStr(e.currentLine(), e.selectionStartCol() - 1, 1) != '#')
                        return;
                    treeNode.AOTedit();
                }
                else
                {
                    treeNode.AOTnewWindow();
                }
            }
        }
 


Click here the origional post....

-Harry

January 02, 2013

How to Restrict Multiple Time login of a same user

Hi Folks,

Many times intentionally or unintentionally a user may open multiple session of AX. That surly impact your performance. So here is a fix,
1.     Go to AOT
2.     Open class ‘Info’
3.     Copy Paste the Following Code in startupPost method.

void startupPost ()
{
// To restrict user login form second login
xSession session;
SysClientSessions SysClientSessions;
UserId currentUserId;
int counter;
;
currentUserId = curUserId();
if(currentUserId!="Admin")// only Admin User is allowed to login multiple time
{
while select SysClientSessions
where SysClientSessions.userId == currentUserId &&
SysClientSessions.Status == 1 // 1 : Login 0 : Logout
{
session = new xSession(SysClientSessions.SessionId, true);
if (session && session.userId())
{
counter++;
}
}
if(counter>=2)
{
Box::stop("Already Logged-in : The same user id can't log in twice.");
infolog.shutDown(true);
}
}
}

Please take backup of your application before copying code

-Harry