Friday, 22 April 2016

Saving AX 2009 Morphx Report in PDF Format:


static void PrinttoPDF(Args _args)
{
  PurchFormLetter purchFormLetterp;
  PrintJobSettings printJobSettings;
  VendInvoiceJour  vendInvoiceJour;
  PrintFormat PrintFormat;
  Args args = new Args();
  #File

    purchFormLetterp = PurchFormLetter::construct(DocumentStatus::Invoice,false);
    printJobSettings = new PrintJobSettings();
    printJobSettings.setTarget(Printmedium::File);
    //printJobSettings.getPrinter();
   // printJobSettings.deviceName("");
   // printJobSettings.unpackPrinterSettings(PurchFormLetter::getPrinterSettingsFormletter(DocumentStatus::Invoice,PrintSetupOriginalCopy::Original));
   // printJobSettings.preferredTarget(PrintMedium::Printer);
    printJobSettings.format(PrintFormat::PDF);
    printJobSettings.fileName( @'c:\TEMP\myfile2.pdf');
    printJobSettings.warnIfFileExists(false);

    purchFormLetterp.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());

    select vendInvoiceJour where vendInvoiceJour.Purchid == 'PO/15-16/00443';
    vendInvoiceJour.printJournal(purchFormLetterp);
   // args.record(vendInvoiceJour);
  //  args.caller(purchFormLetterp);

  // new MenuFunction(menuitemoutputstr(Purchinvoicecopy), MenuItemType::Output).run(args);


}

Code to get the printout directly from a morphx report 2009:

//directly to printer
static void ReporttoPrint(Args _args)
{
    Args                args;
    ReportRun           rr;
    Report              rb;
    PrintJobSettings    pjs;
    VendInvoicejour     record;
    ;

    select record where record.Purchid == 'PO/15-16/00421';

    args = new Args("Purchinvoice");
    args.record(record);
    args.parmEnum(PrintCopyOriginal::OriginalPrint);

    rr = new ReportRun(args,'');
    rr.suppressReportIsEmptyMessage(true);
    rr.query().interactive(false);

    rb = rr.report();
    rb.interactive(true);

    pjs = rr.printJobSettings();
    pjs.fileName(strfmt(@'c:\TEMP\myfile2.pdf', record.purchid));
    pjs.fitToPage(true);

    pjs.virtualPageHeight(-1);
    pjs.format(PrintFormat::PDF);
    pjs.deviceName('Canon iR2220/iR3320 PCL5e');
    pjs.setTarget(PrintMedium::Printer);
    pjs.viewerType(ReportOutputUserType::PDF);
    pjs.lockDestinationProperties(true);
    rr.prompt();
    rr.init();
    rr.run();


}

Tuesday, 8 March 2016

WCF settings error on new AX 2012 AOS installation

It is quite common to have a few different instance installed at Development machine. Sometimes developer make a duplicate copy of client's LIVE environment just to test out some hotfix. Below is one of the scenario which cause the error - "The specified client configuration does not contain valid WCF settings".
Backup an AX 2012 database
Restore as another database name
Install a new AOS instance at another machine
Configure this new AOS to point to the database restored at Step #2
Start up AOS and login to AX
The error "The specified client configuration does not contain valid WCF settings" pops up
Trying to create sales order will throw error (so does a lot of other functionality).

*During the creation of this new instance, the CIL is not recompile

To fix this:

Run a Full CIL generation

On the AX Client Configuration Utility, update the config using Configure Services

WCF error in ax2012:
http://daxdude.blogspot.in/2011/12/error-specified-client-configuration.html

Thursday, 18 February 2016

"Error 1069: The service did not start due to a logon failure."



Error -- Cannot restart AOS, Logon failure , error code 1069

Resolution/Cause -- Goto --> services.msc --> AXService --> Properties --> Logon tab --> Re-enter the user name and password.
Since the user with which the AX Service is running has property "password never expires" not checked and  the pwd has been reset, system throws this error. System verifies the user with AD at the time of restarting the service and finds user/pwd combinantion incorrect.



Windows could not start AX service, AOS crashed, AOCP revision mismatch

All of us would have faced AX service start/crash issue for one or the other reason. A couple of them has been listed below --

Error -- at services.msc

windows could not start the DAX AOS 5.0$01-xyz_ax on local computer.For more information,review the system event log. If this is a non-microsoft service, contact the service vemdor, and refer to service-specific error code 110.
Log at Event viewer --
Concurrent number of AOS' for this application exceeds the licensed number
Resolution/cause -- Get another license for AOS.
-- This issue comes in a scenario where multiple AOS has to connect to a single instance of DB and Application server (clusterred environment).

Error--at services.msc

windows could not start the DAX AOS 5.0$01-xyz_ax on local computer.For more information,review the system event log. If this is a non-microsoft service, contact the service vemdor, and refer to service-specific error code 10.
log at eventvwr --
The home directory for Axapta (file://sqldb/AOSFS/Program Files\Microsoft Dynamics AX\50\Application) does not match the required structure or can not be accessed. Please check installation, configuration and access rights.The directory "file://sqldb/AOSFS/Program Files\Microsoft Dynamics AX\50\Application\bin" does not exist or access to it has been denied by the operating system.

Resolution/cause -- The directory structure should be like --

"  file://sqldb/Program Files\Microsoft Dynamics AX\50\Application ".
------- The mistake I commited was that there was an additional folder structure layer above "Program Files" .

Error -- Internal aocp revision mismatch

At event viewer --
Faulting application Ax32Serv.exe, version 5.0.1500.3761, time stamp 0x4cd58bba, faulting module Ax32Serv.exe, version 5.0.1500.3761, time stamp 0x4cd58bba, exception code 0xc0000005, fault offset 0x00147b3a, process id 0x%9, application start time 0x%10.
Resolution/cause -- This error is raised due to the mismatch between client the AX server. It happens since the client machine is not patched properly. Ideally the client machine should also get patched with the same pack as AX Server.


Error -- AOS crash 
Cause/Resolution -- Due to change in code system was getting stuck in a deadlock and it was first hanged and then getting crashed.
Sol :: check the code, if there is any code ambiguity, any infinite loop, memory leak, reference mismatch while passing parameter by reference. In such cases system does not throw any specific/detail error so it is difficult to find the issue sometimes.

Saturday, 30 January 2016

Error 1053: The service did not respond to the start or control request in a timely fashion in ax 2012 R3

When you start the service u will get one dialog box in that 

Windows could not start the Microsoft Dynamics AX Object Server 6.3$01-MicrosoftDynamicsAX service on Local Computer.

Error 1053: The service did not respond to the start or control request in a timely fashion.

1.There is a standard timeout for starting services. It expects to be started then. Can you confirm if the AOS is started anyway?
2.When you try to start the service manual and don't close the dialog box, you will get the same error. When you click OK, you will notice that the service is in Starting state.
3.It takes some more time, but in the end the AOS should be up and running

Ax 2012 R3 demo data & Test data Transfer Tool download

The contoso demo data for Dynamics Ax 2012 R3 is different from previous version.we used .dat file to load demo data in previous versions. Demo data is available in .exe file.
i.e DynamicsAX2012R3DemoData.exe available in partner Resource.

 Download Ax 2012 R3 demo data


To import this demo data we need  Test Data transfer Tool is available on partner resource.

Go on following link

To import demo data we need to do the following steps.

Step 1:
  • Extract the demo data files from DynamicsAX2012R3DemoData.exe to a specific location.
Step1
  • The output folder will contain the files of following extension types:
  1. .OUT—– data file that contains metadata for AX transactional database
  2. .OutModel —- data file that contain metadata for AX model database
  3. .XML —- data file that contains AX table data.
Step 2:
 Run the Test Data Transfer Tool.Exe file to install the utility.
zb2
  • After successful installation, the folder will look like as shown below:
zb3
Step 3 :
  • Open AX client and import the .XPO named (MetaDataXMLGenerator.Xpo)
zb4
  • On successful import a job will be created as shown below:
zb5
Step 4:
  • Run the job <MetadataXMLGenerator(usr)>, a  meta data file will be generated and the path will be displayed in the infolog as shown in the snapshot below:
zb6
Step 5:
Copy the metadata file from the above path and paste it in [lists] folder (where Test Data Transfer Tool has been extracted). If the file already exists, then overwrite the file.

Step 6 :
Stop MS Dynamics AX service.

Step 7 :
Open command prompt using administrator and navigate to the path where the Test Data Transfer Tool is extracted).

Step 8:
  • Run the following command:
Dp.exe Import “C:\R3DemoData\DynamicsAXR3DemoData” DynamicsAXR3
C:\R3DemoData\DynamicsAXR3DemoData—— update the path (Demo Data extraced path)
DynamicsAXR3—— provide the actual database name.(Ax DB Name)
In case of 3 tier environment, you will get the following screen.





[Server] always looking for current machine.if DB in another server follow step 9. 
Step 9 : you need to install Test data transfer tool on SQL server and run DP command on same server. 
in case of standalone you will get the following screen.
zb7
If we enter ‘Y’, then following screen will open up describing the count for importing the table data and Error (if they come up)
zb8
  • The process may prolong depending upon machine configuration.
  • On successful import, Open AX client and data will show up.

-----------------------------------------------------------------------

Note: Some time system will show below error

“Unhandled Exception: System.UnauthorizedAccessException: Access to the path ‘C:\Program Files (x86)\Microsoft Dynamics AX 2012 Test Data Transfer Tool (Beta)\DP Log.xml’ is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, I
nt32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions o
ptions, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolea
n useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean
bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, Boolean useAsync)
at System.Xml.XmlWriterSettings.CreateWriter(String outputFileName)
at System.Xml.Linq.XDocument.Save(String fileName, SaveOptions options)
at DP.Program.Execute(String currentDirectory, DataportDirection direction, S
tring directory, String database, String server, DataportAction action) in e:\bt
\110700\Source\DataPort\DP\Program.cs:line 182
at DP.Program.Main(String[] args) in e:\bt\110700\Source\DataPort\DP\Program.
cs:line 82


If you are facing the same error than try to run following command (Its same command as above without “ ”)
DP.exe IMPORT C:\AXR3DemoData AX2012R3DB
Now it will work J
As next, Below window will open
clip_image017
Here you done your part, now wait to complete this operation and open your AX client.