Skip to main content

Posts

Writing in the event log from Dynamics AX

static void EventViewer ( Args _args ) {     System. Diagnostics . EventLog eventlog;     #Define. LogSource ( "Dynamics AX" )     #Define. LogName ( "Dynamics AX Log" )         ;     // check if the log already exists     if ( ! System. Diagnostics . EventLog :: SourceExists ( #LogSource ) )     {         // create new log         System. Diagnostics . EventLog :: CreateEventSource ( #LogSource , #LogName ) ;     }     eventlog = new System. Diagnostics . EventLog ( ) ;     eventlog. set_Source ( #LogSource ) ;     // write info entry     eventlog. WriteEntry ( "Just writing in the event viewer." ) ;     // write error entry     eventlog. WriteEntry ( "Error! Please check the stack trace below. \n \n " +         con2str ( xSession :: xppCallStack ( ) ) ,...

Research method on X++ forms

In AX2009 if you call the research() method on a form passing true, the cursor position within a grid should be retained.  However, this is true only if the query created by the form uses inner joins.  Any outer joins, aggregations, temp tables, etc. cause the cursor to go to either the first or last record (depending upon the StartPosition property for that data source).  In 2009 if you want to keep the cursor position and use joins other than inner joins you have to keep track of the cursor position.  Code like the following will do this:     int pos;     super();     pos = salesQuotationTable_ds.getPosition();     salesQuotationTable_ds.research();     salesQuotationTable_ds.setPosition(pos);

Calling a web service from X++ code

In the AOT under the References node add a service reference specifying the wsdl location of the service, a .NET code namespace and a reference namespace.  An example of a wsdl url is: http://myMachine.myDomain/MicrosoftDynamicsAXAif50/salesorderservice.svc?wsdl Once the reference has been created, in X++ create a new class that runs on the server.  In a method in the class write the code that calls the service.  An example of how to call the sales order service is below.  Once the code in the class compiles close the AX client.  Go to the Appl\Standard\ServiceReferences directory and copy the app.config and the generated assembly to the Server\bin directory.     SalesOrder.SalesOrderServiceClient proxyClient;     SalesOrder.AxdSalesOrder salesOrder;     SalesOrder.AxdEntity_SalesTable salesTable;     SalesOrder.AxdEntity_SalesLine salesLine;     SalesOrder.AxdEntity_I...

Changing the language at runtime in X++

We recently had a case where the customer wanted to change the language being used for a given AX user at runtime.  The customer had sorted out how to change the language displayed in forms and reports but the buttons on the navigation pane were not getting updated.  Here is a way to handle this scenario: In the setSetup method of the SysUserSetup form within the if clause add the following:         if (infolog.language() != userinfo.language)         {             infolog.language(userinfo.language);             infolog.navPane().loadStartupButtons();         }

Deploy AX 2009 from Terminal Services with the AX configuration - AX 2009

In my company we were trying to deploy AX 2009 from terminal services and we encountered profiles issues when other users (other than the server admin or domain admin) were trying to access the application. This was strange as we did install the client on a public share, and we also imported the correct configuration for the AX 2009 client. Anyway, I need to give full credit to my company's System Manager. His name is Rohan Robinson and he is truly a master when it comes to Terminal Services and Citrix. His email is rrobinson@argointl.com  in case you have questions for him. So, Rohan came up with the following solution: 1- He installed the AX client on a public share 2- Imported the correct configuration for the client. In here make sure that the configuration file has the correct path as shown below: 3- Moved the configuration file to the bin folder (E:\Program Files (x86)\Microsoft Dynamics AX\50\Client\Bin) 4- Modified the properties in terminal servic...

AX 2009: Citrix & Terminal Server Printing

Errors, or no output when printing from AX to a locally mapped Printer If you are mapping local printers to your TS or Citrix environment and have an issues where nothing is printed or the following error is generated: startDoc: rc:SP_ERROR you will need to change the Print Processor data type from Raw to EMF. This problem occurs because the UPD requires the Enhanced Metafile (EMF) format. By default, Microsoft Dynamics AX creates the print job in the RAW format. (As of AX To modify these printer settings. 1. Click Start, and then click Control Panel. 2. Double-click Printers and Faxes. 3. Right-click the printer that you want to use, and then click Properties. 4. On the Advanced tab, click Print Processor. 5. In the Default data type pane, click NT EMF 1.008, and then click OK. Microsoft Dynamics AX will recognize the EMF format. Additionally, Microsoft Dynamics AX will send the report to the spool file in the EMF format. This is described in further detail in this KB 94752...

How to send emails from AX without requiring Outlook

Sending emails from AX has been somewhat of a pain when it tries to use Outlook.  This post is a simple code modification to one method in \Classes\Info\reportSendMail.  I did not develop this code, I merely tweaked it.  The original poster's blog has disappeared, and I can only find non-working remnants all around the web of this, but it is just too useful not to repost. If you have Outlook 64bit edition, you might get the "Either there is no default mail client or the current mail client cannot fulfill the messaging request.  Please run Microsoft Outlook and set it as the default mail client."  Followed by an AX MAPI error. Or sometimes you may get the "A program is trying to access e-mail address information stored in Outlook."...Allow/Deny/Hlep. This change basically bypasses outlook.  Put it in and give it a shot. void reportSendMail(PrintJobSettings p1) { //SysINetMail m = new SysINetMail(); System.Net.Mail.MailMessage mailMess...