4/25/2017

How to email report in AX 2012 without outlook?

In out of box AX 2012, user has to have outlook to mail the report which is kind of anoying, cause not all of the AX user has outlook. We can find code snipet to bypass outlook to do that online, but you'll notice those codes are only for the old AX report instead of SSRS report. In AX 2012,  the reports are all SSRS reports which means we cannot modify the code in Info\reportSendMail as we did for AX 2009 to bypass outlook.
In fact, it's even easier to do that in AX 2012. In AX 2012, when mailing reports, the class 'SrsReportRunMailer' is executed. What we need to do is just change that class. If you open that class, you'll see the method 'initMailer' decides whether to use SMTP or outlook. When mailing in a batch, it uses SMTP, but when mailing at client, it uses outlook. To change the logic to always go with SMTP, we only need to comment out the 'if' clause and leave the code which takes SMTP. See below,

private void initMailer()
{
    fromAddress = SrsReportRunMailer::buildFromEmailAddress();
    // Always use SMTP, never outlook.
    //if (isRunningOnServer())
    //{
        // get the mailer object
        mailer = this.parmSysMailer();

        // validate the from email addresses
        if (!fromAddress ||
            !SysEmailDistributor::validateEmail(fromAddress))
        {
            error(strfmt("@SYS134596", "@SYS4083"));
            return;
        }
    //}
    //else
    //{
        //inetMailer = new SysINetMail();
    //}



2/24/2017

Access the private project created by other users

Sometimes we do want to access the private project created by other users, e.g. when importing a model we get a private project conflict, to resolve this we have to find the project and delete it. If the owner of those projects are gone, we'll not be able to access them as normal, we'll have to do something unusual to get it.
Even though there're many different approaches to get this resolved in others' blogs/forum, I found my way is probably easiest. Here it is,
1. Find the AX database on SQL server.
2. Open table ModelElement with the private project type only.The private project type is 38.
3. Change the prefix of the private project you are looking for from the original user Id to your user Id by a simple update like.
  update [AX1111_2].[dbo].[ModelElement]
  set Name = 'Admin_AOTExport2012_DynamicsPerfDirect'
  where Name = 'JasonPAdmin_AOTExport2012_DynamicsPerfDirect' and ElementType = 38
4. Reopen AX client with your account, and you'll see the project appears in your private project