Friday, January 30, 2015

Installing EP on desired AOS ( Enterprise Portal installation, 'AOS´XXX# cannot be reached' )

While trying to install the Enterprise portal I came across the following error on the setup :


The AOS 'Name@2712' cannot be reached. Setup cannot continue.Verify that you entered the correct server information an that the AOS is running.


This error is basically because the SetupSupport files pick the wrong/previous/deleted configuration for the Setup. The trick here is that along with the configuration what we fail to update is the Business Connected Proxy Account on the configuration, which normally points to the old server.



Solution :
Navigate to The Client Configuration from Administrative Tools, and change the Client Target to Local Client , and change the configuration to point to the correct AOS.
Navigate to Client Configuration Again, and change the Client Target to Business Connector, and point to the New AOS. 

In some cases
System Admin > Setup > System Accounts had different account mapped. correcting this resolved the issue.

Hope this helps

Tuesday, January 27, 2015

Data import/export framework (AX 2012 R3) - Assembly error [Solved]


Problem :



When open "Data Import \ Export parameters" or any other setup of data import export framework in Ax dynamics 2012 R3 screen system raises the following errors:

Assembly containing type Microsoft.Dynamics.AX.DMF.ServiceProxy.DmfEntityProxy is not referenced
object CLR object could not be created


error in DIEF






















Solution :

  1. Navigate to XppIL folder.My case i navigated to:
    C:\Program Files\Microsoft Dynamics AX\60\Server\axtestserver\bin\XppIL.
  2. Take a backup of all the files in XppIL folder. 
  3. Delete everything inside this folder (Make sure you stopped your AOS service )
  4. Restart the AOS service.
You can now move ahead with setting up Data import/export framework parameters.







Wednesday, May 14, 2014

How To add Ax 2012 R3 Contoso Demo Data

The setup contoso demo data for Dynamics Ax 2012 R3 is different from previous version. I remember, I used .dat file to load demo data into Dynamics Ax 2012 R2. Now DynamicsAX2012R3DemoData.exe available partner Resource.

















DynamicsAX2012R3DemoData.exe extracted files round 15 GB. Extracted folder contains three types of files. According to MSDN


Test Data transfer Tool is available on partner resource.
Go on following link






Login to this and download Microsoft Dynamics Ax 2012 Test Tool Data Transfer (Beta)
There will be zip file downloaded.  On running I found following installation wizard.

















Setup run will be generated as following
Import Data Into Dynamics Ax 2012 R3 instance:
And import MetaDataXMLGenerator.xpo in dynamics Ax.
This xpo imports results a job inside job node under AOT.








This job will generate Metadata.xml. This Metadata.xml will be created in window temporary folder.
Path of file in metadata.xml can be get from infobox which will appear after successful run of job.





if you lost infobox,You can get temporary folder path with following command echo %temp%. where you can get Metadata.xml
Copied metadata.xml into [list] folder of test tool Data folder. If it already exists then overwrite it.





Now open command prompt. Go to directory where Test import tool is extracted.
Run the following command
DP.exe IMPORT “E:\Contoso_Demo_Data\DynamicsAXR3DemoData” MicrosoftDynamicsAx
 MicrosoftDynamicsAx : Its the name of Database..!!
Please update path according to your installation.







After running the command, you will find following window which describe the process by remaining table to number data, and number of error occurs during import.






This process takes hours and hours with respect to your machine. After completion, I found demo data inside my dynamics Ax 2012 R3.

Iace technologies & Services...!!!

Friday, March 21, 2014

AX2012 Import Chart of Accounts from CSV

We have to write Job for doing that...!!!!

static void ImportChartOfAccounts(Args _args)
{
    ChartOfAccountsService                 chartOfAccountsService;
    MainAccountContract                     mainAccountContract;
    CommaTextIo                                 file;
    container                                         rec;
    Name                                             ledgerChartOfAccountsName;
    MainAccountNum                          mainAccountId;
    DimensionLedgerAccountType      dimensionledgerAccountType;

    MainAccount                                 MainAccount;
    DimensionAttribute                         mainAccountDimAttribute;
    DimensionAttributeValue                dimensionAttributeValue;
    DimensionAttributeValueTotallingCriteria    totalCriteria;

    str                    strOfAccounts, fromAtoA;
    int                     sep;
    Dialog               vv    d;
    DialogField         df1, df2;
    ;
    d = new Dialog("Import chart of accounts (main accounts)");
    df1 = d.addField(ExtendedTypeStr("FilenameOpen"));
    df2 = d.addField(extendedTypeStr("Name"), "Chart of account name");

    if (d.run())
    {
        file = new CommaTextIo(df1.value(), 'r');
        file.inFieldDelimiter(';');
        ledgerChartOfAccountsName = df2.value();
        ttsBegin;
        while (file.status() == IO_Status::Ok)
        {
            rec = file.read();
             mainAccountId = strlrTrim(conPeek(rec, 1));
            dimensionledgerAccountType = conPeek(rec, 3);

            if (!mainAccount::findByMainAccountId( mainAccountId , false, LedgerChartOfAccounts::findByName(ledgerChartOfAccountsName).RecId))
            {
                mainAccountContract = new MainAccountContract();
                mainAccountContract.parmMainAccountId( mainAccountId );
                mainAccountContract.parmName(conPeek(rec, 2));
                mainAccountContract.parmLedgerChartOfAccounts(ledgerChartOfAccountsName);
                mainAccountContract.parmType(dimensionledgerAccountType);

                chartOfAccountsService = new ChartOfAccountsService();
                chartOfAccountsService.createMainAccount(mainAccountContract);

                if (dimensionledgerAccountType == DimensionledgerAccountType::Total)
                {
                    strOfAccounts = conPeek(rec, 4);

                    sep = strScan(strOfAccounts, '..', 1, strLen(strOfAccounts));

                    if (sep)
                    {
                        fromA = subStr(strOfAccounts, 1, sep - 1);
                        toA   = subStr(strOfAccounts, sep + 2, strLen(strOfAccounts));
                    }

                    select recid from MainAccount where mainAccount.MainAccountId ==  mainAccountId  ;

                    mainAccountDimAttribute.RecId = DimensionAttribute::getMainAccountDimensionAttribute();

                    dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndEntityInst(mainAccountDimAttribute.RecId, mainAccount.RecId, true, true);

                    totalCriteria.DimensionAttributeValue = dimensionAttributeValue.RecId;
                    totalCriteria.FromValue = fromA;
                    totalCriteria.ToValue   = toA;
                    totalCriteria.insert();
                }
            }
        }
        info("done");
        ttsCommit;
    }

}

Friday, January 10, 2014

How to Restrict Multiple Time login of a same user

X++ Code to restrict user login multiple times in ax2009

Copy Paste the Following Code in startupPost method of info class in AOT

void startupPost()
{
// To restrict user login form second login
xSession session;
SysClientSessions SysClientSessions;
UserId currentUserId;
int counter;
;
currentUserId = curUserId();
if(currentUserId!="Admin")// Allow Admin User 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

Iace Technologies & Services...!!!

How to Read/Write an Excel file through X++ code


In This Post you will found two code sample
1.Write data in excel through X++ code.
2. Read from an Excel through X++ code


1.Write data in excel through X++ code.

static void thaAxapta_Write2Excel(Args _args)
{

InventTable inventTable;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
int row;
;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbook = workbooks.add();
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
cells.range('A:A').numberFormat('@');
cell = cells.item(1,1);
cell.value("Item");
cell = cells.item(1,2);
cell.value("Name");
row = 1;
while select inventTable
{
    row++;
    cell = cells.item(row, 1);
    cell.value(inventTable.ItemId);
    cell = cells.item(row, 2);
    cell.value(inventTable.ItemName);
}
application.visible(true);
}


2. Read from an Excel through X++ code

static void theAxapta_ReadExcel(Args _args)
{

SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row;
ItemId itemid;
Name name;
FileName filename;
;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
//specify the file path that you want to read
filename = "C:\\item.xls";
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();
do
{
    row++;
    itemId = cells.item(row, 1).value().bStr();
    name = cells.item(row, 2).value().bStr();
    info(strfmt('%1 - %2', itemId, name));
    type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
}




Iace technologies & Services...!!!

How to Create Number Sequence In Ax2012

Simple Steps To Create Number Sequence In Ax2012



It is same as like as we know in Ax2009 but small steps is added in AX2012.don't worry just follow the below steps simply we will get number sequence in AX2012.

We will Take a EDT name as "Car Id" and create in number sequence.For that first we should select a module for new number sequence for example project module.

Steps

1. Create an edt : CarId .
AOT >> Extended Data Types >> New >> Properties >> Name >> Car Id.



2. Write a code on lode module() on NumberSeqModuleProject

{
     datatype.parmDatatypeId(extendedTypeNum(Car Id));
     datatype.parmReferenceHelp(literalStr("@SYS334483"));
     datatype.parmWizardIsManual(NoYes::No);
     datatype.parmWizardIsChangeDownAllowed(NoYes::No);
     datatype.parmWizardIsChangeUpAllowed(NoYes::No);
     datatype.parmWizardHighest(999999);
     datatype.parmSortField(20);
     datatype.addParameterType(NumberSeqParameterType::DataArea, true,        false);
     this.create(datatype);
}

3. Write a method on Projparameters Table

    client server static NumberSequenceReference numRefcarId()
     {
      return NumberSeqReference::findReference(extendedTypeNum(car Id));
     }


4. Write a job and run that

static void Carid(Args _args)
{
    NumberSeqModuleProject  NumberSeqModuleProject = new NumberSeqModuleProject();
    ;
    NumberSeqModuleProject.load();
}


5. Then run the wizard
Organization Administration >> CommonForms >> Numbersequences>>Numbersequences>> Generate >> run the wizard.

6. Now we have to check the number sequence  is correctly working  for that write a job:

static void number(Args _args)
{
    NumberSeq  numberSeq;
    CarId num;
    ;
    numberSeq = NumberSeq::newGetNum(ProjParameters::numRefcarId());
    num = numberSeq.num();
    info(num);
}

7. Now we want that Number Sequence in form level(Car Table):

Declare the number sequence On Form Declaration:
 
public class FormRun extends ObjectRun
{
    NumberSeqFormHandler numberSeqFormHandler;

}

 8. Write the NumberSeqFormHandler() in form methods node.

NumberSeqFormHandler numberSeqFormHandler()
{
    if (!numberSeqFormHandler)
    {
        numberSeqFormHandler = NumberSeqFormHandler::newForm(ProjParameters::numRefcarId      ().NumberSequenceId,
                                                             element,
                                                             CarTable_DS,
                                                             fieldNum(CarTable, Car Id)
                                                            );
    }
    return numberSeqFormHandler;
}
9.Write the close() on the form methods node.

void close()
{
    if (numberSeqFormHandler)
    {
        numberSeqFormHandler.formMethodClose();
    }
    super();
}

10. Then final add the below methods on data source methods node
Create()

void create(boolean append = false,
            boolean extern = false)  // If created externally
{
    element.numberSeqFormHandler().formMethodDataSourceCreatePre();

    super(append);

    if (!extern)
    {
        element.numberSeqFormHandler().formMethodDataSourceCreate(true);
    }
}

Delete()

public void delete()
{
    element.numberSeqFormHandler().formMethodDataSourceDelete();
    super();
}

Write()

public void write()
{
    super();
    element.numberSeqFormHandler().formMethodDataSourceWrite();
}

Validate Write()

public boolean validateWrite()
{
    boolean         ret;
    ret = super();
    ret = element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret) && ret;
    if (ret)
    {
        CarTable.validateWrite();
    }
    return ret;
}

Link Active()

public void linkActive()
{
    ;
    element.numberSeqFormHandler().formMethodDataSourceLinkActive();
    super();
}
Now our numberseqence is generated .

*** Set the field or Tabpage Allowedit property to No.
***Check the continues on wizard.