Thursday, 12 December 2013

Filter ListPage



The filter definition is placed directly on CtrlActiveAll control in ProjProjectsListPage form. You can see there:
FilterDataSource: ProjTable
FilterField: Status
FilterExpression: (projActiveAll(%1))
And projActiveAll() is defined in SysQueryRangeUtil class.

  • Create new Method in SysQueryRangeUtil  class

public static str DNAgreementActive(DNActive _DNActive)
{
    switch(_DNActive)
    {
        case DNActive::All:
            return SysQuery::valueUnlimited();
        case DNActive::Active:
            return SysQuery::value(noyes::Yes);
        case DNActive::InActive:
            return SysQuery::value(noyes::No);
        default:
            return SysQuery::valueUnlimited();
    }
}

Wednesday, 11 December 2013

AX 2012 R2 CU7 Compile application

If the AX version is R2 with CU7, then don’t waste your time for compilation around 6 hours.

Use the following steps to have the compilation with 30 to 1 hour based on the system speed. Use the Command prompt to run the compilation.
There is new AXBuild.exe tool available from MS in the server folder. Path is
[Drive:] cd\Program Files\Microsoft Dynamics AX\60\Server\<YOUR AOS NAME>\bin

Use the path in CMD using cd command. And run the following command.

axbuild.exe xppcompileall /aos=01 /altbin="C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin" /workers=4               

where  
/aos = 01 is number of the AOS available in the server. AOS number will be identified in the AX Server configuration utility. It will be like 01,02,etc..
/worker = 4, give based on the server processor core. Count the number of code in the processor in Device Manager and give the number after “/worker =”.

You can the compilation output in the folder C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\Log\ as a HTML file.
You can import it in AX output window in Dev environment and resolve the errors.


Tuesday, 3 December 2013

Error “For more information about this error navigate to the report server on the local server machine, or enable remote errors” when opening SSRS Report in AX

Error “For more information about this error navigate to the report server on the local server machine, or enable remote errors” when opening SSRS Report in AX


Resolution:  Generate Incremental CIL


1. First Check Local business connector is  correct.
2. And Check Domain business connector is  correct.
3. Then Put increment CIL


For me it had solve the problem

Thursday, 7 November 2013

X++ Code to import Movement journal from excel in ax 2012

static void InventoryClosingImportJob(Args _args)
{
     InventJournalTable journalTable;
    InventJournalTrans journalTrans;
    InventJournalTableData journalTableData;
    InventJournalTransData journalTransData;
    InventTable inventTable;
    InventDim locInventDim;
    Counter cnt;
    ItemIdInventoried       Itemid;
    InventSiteId            inventSiteId;
    InventLocationId        inventLocationId;
    InventBatchId           inventBatchId;
    InventQtyJournal        qty;
    ItemCostPrice           costprice;
    LedgerDimensionDefaultAccount   mainacc;
    str                20     mainaccStr;
    container            offSetEntryPattern;
    LedgerJournalId               JournalId;

    SysExcelApplication             application;
    SysExcelWorkbooks               workbooks;
    SysExcelWorkbook                workbook;
    SysExcelWorksheets              worksheets;
    SysExcelWorksheet               worksheet;
    SysExcelCells                   cells;
    COMVariantType                  type;

    FilenameOpen                    filename;
    dialogField                     dialogFilename;

    Dialog                          dialog;
    Integer                         row = 1;
    int     coun;

    Mainaccount     mainaccount;
    int   _mainaccountnum; //= "111200";//"202000";
    Ledger          ledger;
    CompanyInfo     companyinfo;


    str COMVariant2Str(COMVariant       _cv)
    {
        switch (_cv.variantType())
        {
            case (COMVariantType::VT_BSTR):
                return _cv.bStr();

            case (COMVariantType::VT_R8):
              //  return _cv.toString() ;
                return _cv.bStr() ;
            case (COMVariantType::VT_DATE):
                return date2str(_cv.date(),123,2,1,2,1,4);

            case (COMVariantType::VT_EMPTY):
                return '';

            default:
                throw error(strfmt("@SYS26908", _cv.variantType()));
        }
    }
    ;

    dialog              =   new Dialog('Import Vendor Details');
    dialogFilename      =   dialog.addField(ExtendedTypeStr("FilenameOpen"));

    dialog.filenameLookupTitle('Import from excel.');
    dialog.caption('Import From Excel');

    dialogFilename.value(filename);

    if(dialog.run())
    {
        filename            =   dialogFilename.value();

        application         =   SysExcelApplication::construct();
        workbooks           =   application.workbooks();

        try
        {
            workbooks.open(filename);
        }
        catch (Exception::Error)
        {
            throw error('File cannot be opened.');
        }

        workbook            =   workbooks.item(1);
        worksheets          =   workbook.worksheets();
        worksheet           =   worksheets.itemFromNum(1);
        cells               =   worksheet.cells();
     
        try
        {
            ttsbegin;
            // NOTE - JOURNAL ID MUST BE CHANGED BEFORE IMPORT
            Select journalTable Where journalTable.JournalId =="TN-000052"; //CHANGE JOURNAL ID HERE
            do
            {
                row++;
            itemId                                  = cells.item(row, 1).value().bStr();
            inventSiteId                            = cells.item(row, 2).value().bStr();
            inventLocationId                        = cells.item(row, 3).value().bStr();
            inventBatchId                           = cells.item(row, 4).value().bStr();
            qty                                     = cells.item(row, 5).value().double();
            costPrice                               = cells.item(row, 6).value().double();

            _mainAccountNum                         = cells.item(row, 7).value().double();
            mainAccstr                              = int2str(_mainaccountnum);
            //department                            = cells.item(row, 8).value().bStr();

            JournalId                               = cells.item(row, 9).value().bStr();

            type = cells.item(row+1, 1).value().variantType();
            select recId from MainAccount where mainAccount.MainAccountId ==mainAccstr;

            locInventDim.inventBatchId              = inventBatchId;
            locInventDim.InventSiteId               = inventSiteId;
            locInventDim.InventLocationId           = inventLocationId;
            journalTrans.clear();
            journalTrans.initFromInventJournalTable(journalTable);
            journalTrans.TransDate                  = cells.item(row, 8).value().date();//systemDateGet();
            journalTrans.ItemId                     = itemId;
            journalTrans.JournalId                  = journalTable.JournalId;//JournalId;//

            //Finding out the invent dim id from given value
            journalTrans.InventDimId                = InventDim::findOrCreate(locInventDim).inventDimId;
            journalTrans.PriceUnit                  = 1;
            journalTrans.Qty                        = qty;
            journalTrans.CostPrice                  = costPrice;
            journalTrans.CostAmount                 = journalTrans.Qty * journalTrans.CostPrice;

            journalTrans.LedgerDimension            = DimensionStorage::getDefaultAccountForMainAccountNum(mainAccstr);
            //Except these below two lines above things are same as like in dynamics AX 2009
            //If you want to insert the dimension value with account
            //In below code I have no dimension with main account so I just put 0, Instead I have two
            //dimension
            //write a code like “[“MainAccount”, mainAcc, 2, Dinemsion1, dimVal1, Dimension2, dimVal2)
            // offsetEntryPattern                                      = [mainAccstr,0,0];
            // journalTrans.LedgerDimension              = AxdDimensionUtil::getLedgerAccountId(offsetEntryPattern);
            //Default dimension Value either you can insert the dimension value here.
            //defaultDim                                                     = [1,"Department",department];
            //journalTrans.DefaultDimension             =        AxdDimensionUtil::getDimensionAttributeValueSetId(defaultDim);
            journalTrans.insert();

            coun++;
            print(coun);
            }
            while (type != COMVariantType::VT_EMPTY);
            info(int2str(coun));
            ttscommit;
            application.quit();
        }
        catch
        {
            throw error('Error in import.');
        }
    }

}

X++ Code for importing Movement Journal from excel in ax 2009

static void createInventoryJournal_sever(Args _args)///and also it will import the data from the Excel
{
InventJournalNameId inventJournalNameId = "IMov";///Assign the journal Name
AxInventJournalTrans axInventJournalTrans;
InventJournalTable inventJournalTable;
Dialog dialog;
DialogField dialogField,dialogdate;
Filename filename;
COMVariant cOMVariant;
SysExcelApplication sysExcelApp;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell rCell;
int i,j,k;
date date1;
SysOperationProgress simpleProgress;
Container filterCriteria;
#avifiles
;
date1 = mkdate(30,10,2013);
sysExcelApp = SysExcelApplication::construct();///SysExcelApplication
workbooks = sysExcelApp.workbooks();///Workbooks

Dialog = new dialog();
dialogField = dialog.addField(typeId(FileNameOpen),'File Name');
filterCriteria = ['*.xls'];
//ilterCriteria = ['*.xls','*. xlsx'];//// To filter only Excel files
filterCriteria = dialog.filenameLookupFilter(filterCriteria);
dialog.run();
if(dialog.run())
fileName = dialogField.value();

cOMVariant = new COMVariant();
cOMVariant.bStr(fileName);

workBook = workBooks.add(cOMVariant);///Workbook
worksheets = Workbook.worksheets();///WorkSheets
worksheet = worksheets.itemFromNum(1);///WorkSheet
Cells = workSheet.cells();///Cells

i=2;
rCell = Cells.item(i,1);///rCell

if(fileName)
{
ttsBegin;
inventJournalTable.JournalNameId = inventJournalNameId;
inventJournalTable.initFromInventJournalName(InventJournalName::find(inventJournalNameId));
inventJournalTable.JournalId = "000262_070";
inventJournalTable.insert();
simpleProgress = SysOperationProgress::newGeneral(#aviUpdate,'Importing Transactions',100);///SysProgressOperation
while(RCell.Value().bStr() != '')
{
j++;
simpleProgress.incCount();
simpleprogress.setText(strfmt("Transaction Imported: %1",i));
sleep(10);
simpleprogress.kill();
axInventJournalTrans = new AxInventJournalTrans();
axInventJournalTrans.parmJournalId(inventJournalTable.JournalId);
axInventJournalTrans.parmTransDate(date1);//systemdateget());
axInventJournalTrans.parmLineNum(j);

//axInventJournalTrans.parmLedgerAccountIdOffset("99999");
rCell = Cells.Item(i, 1);
axInventJournalTrans.parmItemId(RCell.value().bStr());
rCell = Cells.Item(i, 2);
axInventJournalTrans.axInventDim().parmInventSiteId(rCell.value().bStr());
rCell = Cells.Item(i, 3);
axInventJournalTrans.axInventDim().parmInventLocationId(rCell.value().bStr());
/*rCell = Cells.Item(i, 2);
axInventJournalTrans.axInventDim().parmInventSiteId(rCell.value().bStr());*/
rCell = Cells.Item(i, 5);
axInventJournalTrans.parmQty(Rcell.value().double());
/*ell = Cells.Item(i, 5);
axInventJournalTrans.parmQty(rCell.value().double());*/
rCell = Cells.Item(i, 6);
axInventJournalTrans.parmCostPrice(rCell.value().double());
axInventJournalTrans.save();
i++;
rCell = Cells.Item(i, 2);
}
ttsCommit;
}
}

Saturday, 26 October 2013

Enterprise Portal With SharePoint 2013 Installation & Configuration For Microsoft Dynamics AX 2012 R2

In this blog, I will talk about how to install and configure the Enterprise Portal for Dynamics Ax 2012 R2.
Before installing the enterprise portal, we have to check compatibility of the system, and install valid prerequisite before which is essential for the Dynamics Ax 2012 R2 Enterprise Portal.

Let’s start inspection of system requirements.

  • Open the Microsoft Dynamics AX 2012 R2 setup.
  • Click on “validate system requirements” option.

  • Check the “Enterprise Portal” checkbox from the list of components and then click on validate button.
  •  Install the Pre-requisite listed below in the result.

     
The essential prerequisite for Enterprise Portal is SharePoint Foundation/Server. Here I am installing SharePoint 2013 Foundation. 

  • Download the following Prerequisites & install it manually:
·        .NET Framework 4.5
http://download.microsoft.com/download/D/3/0/D30186E3-C7E0-4FD2-8775-FC3B90062B49/dotNetFx45_Full_x86_x64.exe 
·        Windows Management Framework 3.0
http://download.microsoft.com/download/5/2/B/52B59966-3009-4F39-A99E-3732717BBE2A/Windows6.1-            KB2506143-x64.msu
·        Microsoft SQL Server 2008 R2 Native Client
http://download.microsoft.com/download/9/1/3/9138773A-505D-43E2-AC08-9A77E1E0490B/1033/x64/sqlncli.msi
·        Windows Identity Foundation
http://download.microsoft.com/download/D/7/2/D72FD747-69B6-40B7-875B-C2B40A6B2BDD/Windows6.1-KB974405-x64.msu
·        Microsoft Sync Framework v1.0 SP1 x64
http://download.microsoft.com/download/E/0/0/E0060D8F-2354-4871-9596-DC78538799CC/Synchronization.msi
·        Windows Server AppFabric
http://download.microsoft.com/download/A/6/7/A678AB47-496B-4907-B3D4-0A2D280A13C0/WindowsServerAppFabricSetup_x64.exe
·        Microsoft Identity Extensions
http://download.microsoft.com/download/0/1/D/01D06854-CA0C-46F1-ADBA-EBF86010DCC6/r2/MicrosoftIdentityExtensions-64.msi
·        Microsoft Information Protection and Control Client
http://download.microsoft.com/download/9/1/D/91DA8796-BE1D-46AF-8489-663AB7811517/setup_msipc_x64.msi 
·        Microsoft WCF Data Services 5.0
http://download.microsoft.com/download/8/F/9/8F93DBBD-896B-4760-AC81-646F61363A6D/WcfDataServices.exe
·        Cumulative Update Package 1 for Microsoft AppFabric
http://download.microsoft.com/download/7/B/5/7B51D8D1-20FD-4BF0-87C7-4714F5A1C313/AppFabric1.1-          RTM-KB2671763-x64-ENU.exe

  • Install software prerequisites from the setup of SharePoint Foundation 2013, it will configure “Application server and Web IIS” after that it will automatically install the Windows Server AppFabric and its updates...

     
  • If after installation, the AppFabric server installation shows any error then do as follows…
My computer \ Properties \ System \ Advanced System Settings \ Environment Variables \ System Variables
PSModulePath - C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;c:\Program Files\AppFabric 1.1 for Windows Server\PowershellModules
  • Once the installation will be finished, it will automatically open the SharePoint Products Configuration Wizard, cancel the product configuration wizard and then install “KB2768000” update for SharePoint 2013.  

    After that you can start the SharePoint product configuration wizard, you can start it from
Start > All Programs > Microsoft SharePoint 2013 Products > SharePoint 2013 Products Configuration Wizard
  • Select the new server farm for SharePoint, which is creating a new server farm in the system and then add our server into the new server farm, or else you can connect with any existing server farm by using the passphrase of that server farm.

     
  • Specify your database server name, Username and Password
     
  • Specify your custom port number or you can use the system generated port number as well, choose NTLM as an authentication provider

     
  • It gives summary of the configuration settings, which will be applied, click on the NEXT button and it will start the configuration process
  
  • It will take a little long time to configure the SharePoint product

  • Specify the farm security passphrase, which is used when you want connect another server with this farm
     
  • Hit the FINISH button and SP 2013 will be configured  

  • It will create a new “Config” database, “Admin content” database & other required databases in SQL server for SharePoint like below image. 


After clicking on finish, it will open the configuration wizard in your default browser.

  • Before the configuration of product in the IIS manager, the default SharePoint 80 site is not exist, refer below image
  • Now START the wizard in the browser, which is open after FINISH the product configuration wizard
  • Specify existing or create new management account and do NEXT
  • Specify the title & description of your team site or you can also skip the below step & click on OK button
  • Do FINISH the wizard


  • Now you can see the default SharePoint 80 site on the IIS manage after completing all the configuration wizards. The configuration wizard that helps you to create & configure SharePoint 80.
  • SharePoint 80 site would appear as such below in the browser  
After that open the SharePoint central admin

  • Open manage service on order
  • In that find claims to windows token service, if it is in stop status then start it.
  • After that restart the PC.

Install the EP from 2012 R2 setup.

  • Open the setup of Microsoft Dynamics AX 2012 R2

     
  • Select Add or Modify Component
  • Select Enterprise Portal from component list & do NEXT

     
  • After validation on requirement click NEXT

     
  • Specify a user name and a password for the business connector

        
  • It will use the default SharePoint 80 to create the Enterprise Portal site for Dynamics AX
  
  • Again it will validate the requirement for the Enterprise Portal, Once that finishes do NEXT

     
  • Now click on the Install button and it will start installing the Enterprise Portal for Microsoft Dynamics AX 2012 R2

       
    The installation may take some time

        
  • Finish the installation