Sunday 24 August 2014

The report server has encountered a configuration error. Logon failed for the unattended execution account. (rsServerConfigurationError)

Complete Error:

The report server has encountered a configuration error. Logon failed for the unattended execution account. (rsServerConfigurationError)
 Log on failed. Ensure the user name and password are correct. (rsLogonFailed)

 Logon failure: the specified account password has expired.

Solution:

Go to Start > Reporting Service Configuration Manager > open tab Execution Account


Now enter the correct credentials.

Then try running the report again.The error must be gone.

Deploying SSRS Reports using PowerShell in AX 2012

This is to describe more in detail about Deploying SSRS Reports from Microsoft PowerShell:


To open Microsoft PowerShell:

Go to Administrative tools > Microsoft Dynamics AX 2012 management shell(run as administrator to avoid any unexpected errors)

The Microsoft PowerShell window opens up:


As you can see this is not the basic Windows Powershell.This will import four different modules on its own.
"C:Windows\system32> Get-Command" will get you all the commands available.



  • To Deploy your report type the command:

C:Windows\system32> Publish-AXReport -ReportName DemoReport1

This will deploy single report named "DemoReport1".


  • To Deploy all the SSRS reports type in the command:

C:Windows\system32> Publish-AXReport -ReportName *

This will deploy all the SSRS Reports to the Reporting Server.


  • Here is a little trick to deploy specific reports:

C:Windows\system32> Publish-AXReport -ReportName XYZ_*

This will deploy all the reports starting with the name "XYZ_" .So we can use our project naming prefix here to deploy all the reports made for a particular functionality as wildcard is supported here.


  • Another note to check the server configuration is:

C:Windows\system32> Test-AXReportServerConfiguration

Try running this before you start.If everything is set to true here we are good to go.


Note: The Microsoft Dynamics AX 2012 Management Shell is very powerful and fast.To deploy 1000 reports it would take only about 10mins which would have taken approx 45mins for 200 reports in AX 2009 SSRS.

Thanks,

Wednesday 20 August 2014

Calling SSRS Report from X++ code.

Run SSRS Report without a modified contract using X++ code

static void Job_RunSSRSReport(Args _args)
{

///srsreportruninterface class provides a set of APIs to run report programmatically.
SrsReportRunInterface        reportRun;

//Create an instance of the report
//Pass in the report that you want to run by using the syntax
// '<ReportName>.<DesignName>'
reportRun           =        new    SrsReportRunImpl('SampleReport.Design');

// Run the report that is passed.

reportRun.runReport();

}

Tuesday 19 August 2014

Global Address Book Transition from AX 4.0 to AX 2012

Address transition from AX 4.0 to AX 2012

In Microsoft Dynamics AX 4.0:

Entity's data was stored in the entity table itself.
e.g: CustTable holds consumer name,contact information and address.


In Microsoft Dynamics AX 2009:

Although Global Address Book was introduced it was not fully functional.The entity tables still holds the entity data but the data is synchronized to global address book tables.


In Microsoft Dynamics AX 2012:

Now data is just stored in the global address book tables.The transition is complete and now there is no need of synchronization.
Also it is global data i.e one record per entity for one system.Unlike previous versions where it was stored one record per entity for every company.
So address data duplication has reduced to a large extent.

  

Saturday 16 August 2014

Ways to open AOT in AX 2012

Ways to open AOT/Developer workspace in AX 2012:

  1. Press Ctrl-Shift-W.
  2. Navigate to Windows > New Development Workspace.
  3. Press CTRL + D.
  4. Add the -development switch to the ax32.exe command when starting Microsoft Dynamics AX.


Note:
Once the development workspace is open we can add multiple AOT's by pressing CTRL+D.This is helpful in using the drag n drop functionality. 


The port 'TestServiceGroup' could not be deployed.\nError: The port 'TestServiceGroup' has no service operations.

Solution:

This error comes up when we are trying to deploy a service group and create a inbound port.
And the service that is added to the service group has no operations added to it.


  • Go back to AOT > Service >'Service with error' >Operations > right-click and click Add Operation.
  • A new 'Add Service Operations' form is opened up.
  • Select the Operations to be added by marking the checkbox >Add.
  • This will add the operations to the service and the service group will now deploy without any errors.


Note: 

  • Operations once added will not be visible in the form.
  • The operation is a method of the service contract class and applies the [SysEntryPointAttribute] to it.

Tuesday 12 August 2014

Export to excel in AX using X++

Export AX data to excel file using X++ code and with a directory select option.
Use the following code:

static void Export_to_excel(Args _args)
{
   //Excel classes
   SysExcelApplication          xlsApplication;
   SysExcelWorkBooks            xlsWorkBookCollection;
   SysExcelWorkBook             xlsWorkBook;
   SysExcelWorkSheets           xlsWorkSheetCollection;
   SysExcelWorkSheet            xlsWorkSheet;
   SysExcelRange                xlsRange;
   //tables used
   CustTable                    custTable;
   BILLDetailsTable             billdetailstable;
   CustTransHistoryTable        custtranshisttable;
   CustTransHistoryLines        custtranshistlines;
   //variables
   int                          row = 1;
   str                          fileName;
   transdate                    frmdate,todate;
   Area                          area;
   //Dialog instances
   Dialog                       dlg;
   DialogGroup                  dlgGroup;
   DialogField                  digfield,digfield1,digfield2;
   DialogField                  dialogFilename;
   ;
 
    dlg         = new Dialog("AX Export");
    dlgGroup    = dlg.addGroup("Enter details");
    digfield    = dlg.addField(TypeID(transdate),"From Date");
    digfield1   = dlg.addField(TypeID(transdate),"To Date");
    digfield2   = dlg.addField(TypeID(MIDCarea),"Area");
     //this will provide directory window where you can save the file.Don't forget to write a filename at the end of the path.
     //e.g C:\newexcel.xls
    dialogFilename = dlg.addFieldValue(typeid(Filepath),filename);

    dlg.run();
    frmdate     =digfield.value();
    todate      =digfield1.value();
    area        =digfield2.value();

    if(!frmdate||!todate||!area)//validating dialog values
    {
     throw error("Enter complete data");
    }

     //Filename
   fileName = dialogFilename.value();
   //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("CustAccount");
   xlsWorkSheet.cells().item(row,2).value("PaymentVoucher");
   xlsWorkSheet.cells().item(row,3).value("ReceiptDate");
   row++;
   //newcode


    while select  custtranshisttable
    order by custtranshisttable.CustAccount
    where custtranshisttable.Area == area
    && custtranshisttable.ReceiptDate >= frmdate
    && custtranshisttable.ReceiptDate <= todate
    {
    while select sum(amountsettled),ItemId,InvoiceId from custtranshistlines
    group by custtranshistlines.ItemId
    where custtranshistlines.PaymentReceiptID == custtranshisttable.PaymentReceiptID
    && custtranshistlines.InvoiceId == custtranshisttable.InvoiceNo//current
            {
                    xlsWorkSheet.cells().item(row,1).value(custtranshisttable.CustAccount);
                    xlsWorkSheet.cells().item(row,2).value(custtranshisttable.PaymentVoucher);
                    xlsWorkSheet.cells().item(row,3).value(custtranshisttable.ReceiptDate);
                    row++;//current row is complete now incrementing to new row.
            }
    }
   //Check for duplicate files
   if(WinApi::fileExists(fileName))
      WinApi::deleteFile(fileName);//if found delete it
   //Save Excel document
   xlsWorkbook.saveAs(fileName);
   //Open Excel document
   xlsApplication.visible(true);
   //Close Excel
   xlsApplication.quit();
   xlsApplication.finalize();
}

Sorry for bad editting :P

Thanks

Calling number sequence from X++code in AX

At times we need to call the next number from a particular number sequence using X++ code.
Following is the code to do so:

static void numberSeq_Demo(Args _args)
{
NumberSeq    numberSeq;
int                   nextNo;
;
ttsbegin;

numberSeq = numberSeq::newGetNum
(NumberSeqReference::findReference(typeid2extendedtypeid(typeid(WaterConApplicationId))));
//WaterConApplicationId is the EDT that is used to create the number sequence.
info(numberSeq.num());

numberSeq = numberSeq::newGetNum
(NumberSeqReference::findReference(typeid2extendedtypeid(typeid(CustRelNo))));

nextNo =  numberSeq.num();

//info(strfmt("%1",nextNo));

ttscommit;
}

Sunday 10 August 2014

The server-side impersonated (RunAs) session tried to invoke a method that is available for client-side processing only.

Solution:
Follow these steps to solve the issue

  • Open the RunBaseBatch Class in AOT>Classes.
  • Override the runsImpersonated() method.
  • replace return true; by return false;

This shall solve the problem.

Thanks

Function to get last day of month in AX

Code to find the last day of month in Ax.

static void LastOfMonth(Args _args)
{
   TransDate transDate=today();
   TransDate LastOfMth;
   ;

   //LastOfMth=endmth(mkdate(1,1,2014));//To enter date using business logic.
   LastOfMth=endmth(transDate);

   info(date2str(LastOfMth,123,2,2,2,2,4));
}

Moving object between layers.

There is a very simple way to move objects between layers in AX.
I will try to explain it using an example.

E.g. Moving objects from USR layer to CUS layer.

Follow these steps:
  • Logon to the USR layer.
  • Export the object that is suppose to be moved to CUS layer.
  • Now delete the object in the USR layer.
  • Logon to CUS layer.
  • Import the xpo from the USR layer in the CUS layer.
We have successfully moved the objects from USR layer to CUS layer.All the changes are on USR layer now for this object.

Note: Always start from uppermost layer(USR->SYS) when the changes are on multiple layers.Also it is a good practice to make a project in case of multiple objects.Same steps should be followed on the project.

Thanks

Saturday 2 August 2014

Ways to deploy SSRS Reports in AX 2012

There are 3 ways to deploy a AX 2012 SSRS report.

1)From Microsoft Dynamics AX(The reporting project needs to be added to AOT first for this option.)

  • Open the Development Workspace.
  • Find the report you have to deploy in SSRS Reports > Reports
  • Right-click and click Deploy Element.

2)From Microsoft Visual Studio
  • In the Solution Explorer right-click on the reporting project that contains the report.
  • Click Deploy.

3)From Microsoft PowerShell
  • This supports deploying multiple reports at a time.
  • For more details see AX 2012 PowerShell

Note: The SSRS report that is created has to be deployed to the reporting server.Till then it is not available for the users.