Posts

Showing posts from 2012

Import Opening Stock Balance into Dynamics AX

Image
Import Opening Stock Balance into Dynamics AXWhen we import opening stock balance into inventory journal using the standard import/export functionality, the most common problem is dealing with Inventory Dimension id (InventDimId). We might know the warehouse and batch, but we do not know what is the InventDimId that represents the combination of these two inventory dimension.
One way to do this is to lookup the InventDimId value manually before performing the import. This is only possible if very few inventory dimensions are used.

An alternative is using the Custom import functionality to import stock balance CSV file into Tag counting journal.
There is a conversion functionality in the Custom import, where you can write a little X++ code to find the InventDimId using the inventory dimensions.
Here is an example of finding the InventDimId using Site and Warehouse dimension.



You must select Run conversion checkbox to activate the conversion. You may also use the compile icon (on the right …

Change company from the current company in X++ code

Change company from the current company in X++ codeIf in any point you need to change change company during the code, This example will helps you to change the company from current company in x++ code.

static void main()
{
  CustTable custTable;
  ;
  //Assume that you are running in company 'DAT'.
  changeCompany('DAT1') //Default company is now 'DAT1'.
  {
    custTable = null;
    while select custTable
    {
       //custTable is now selected in company 'DAT1'.
    }
  }
 //Default company is again set back to 'DAT'.
 changeCompany('DAT2') //Default company is now 'DAT2'.
 {
   //Clear custTable to let the select work
   //on the new default company.
   custTable = null;
   while select custTable
    {
      //custTable is now selected in company 'DAT2'.
    }
 }
//Default company is again 'DAT'.
}

-Harry.

Upgrading to Microsoft Dynamics AX 2012

Dynamics Ax Layers

Dynamics Ax LayersDynamics AX 2009 consists of sixteen application object layers that contain all the
elements you see in the AOT.
These layers can be looked at as an onion with multiple layers. In the middle is the
core application in the SYS layer and the outermost layer is the user layer USR.
Therefore, when any application element is being executed the system will look at
the outermost code layer first to see if there is any code for that element; if not, it peels a layer off the onion, and tries the next layer. When it hits a layer where the element exists, it will use the code from this layer, and will not continue to peel off layers to find code for that element in the innermost layers.
Layers with their description


SYS The standard application is implemented at the lowest level,
the SYS layer.The application objects in the standard
application can never be deleted.

GLS Country/region specific changes will be developed in GLS
Layer.For e.g as you all know that Tax structure differs
from …

Workflow configuration error in Dynamics Ax: 401 Unauthorized

Workflow configuration error in Dynamics Ax: 401 Unauthorized
Some times we faced unusual error after installing Dynamics AX Workflow: “401 Unauthorized” after running Workflow infrastructure configuration wizard
(Dynamics AX –> Administration –> Setup)
at the first time installation of Dynamics Ax then you should go through the following steps….
It is mainly happening when database, AOS, Application and workflow servers are individual (especially workflow & AOS and Database server)
Check AOS Service is running under an active domain user (domain\username) Workflow website and workflow application pool are having the same .NET Business Connector user name Identity (and of course, this should be an active domain user) You added the workflow website (http://servername:portnumber/DynamicsAXWorkflow50 for example) to the trusted sites in Internet Options of AOS server Run the following on the Workflow server:After checking above points and then perform the following stepsStart a c…

Open web pages from X++ code

Sending mail from AX using .NET FrameworkSometimes happen that SysMailer class (using CDO) is not the right solution for sending mails with attachments. There is a little sample of X++ Job that is using System.Net.Mail namespace to achieve same.


static void JobNETSendMail(Args _args) { System.Net.Mail.MailMessage mailMessage; System.Net.Mail.Attachment attachment; System.Net.Mail.AttachmentCollection attachementCollection; System.Net.Mail.SmtpClient smtpClient; System.Net.Mail.MailAddress mailAddressFrom; System.Net.Mail.MailAddress mailAddressTo; str strBody; str strSMTPServer; str strFileName; FileIOPermission perm; ; // preparing parameters mailAddressFrom = new System.Net.Mail.MailAddres"test@localmail.com", ""); …

The MorphX Tools - Project Designer

Image
How to Create a Project in AXaptaFor a fully customizable overview of the elements, you can use projects. In a project, elements can be grouped and structured according to the developer’s preference. The Project Designer is a powerful alternative to the AOT because you can collect all the elements needed for a feature in one project.Creating a New ProjectYou open the Project Designer by clicking the Project button on the toolbar. Figure 1 shows the Project Designer and its Private and Shared projects.

Figure 1. Project Designer, showing available private and shared projects

Except for its structure, the Project Designer behaves exactly like the AOT. Every element in a project is also present in the AOT.
When you create a new project, you must decide whether it should be private or shared among all developers. You can’t set access requirements on shared projects. You can make a shared project private (and a private project shared) by dragging it from the shared category into the private c…

How to go to the object from Infolog

Image
How to go to the object from InfologWhen we print a transaction id through infolog Usually, it is more useful if the user can go directly to the object from an Infolog line.

For example, we need to see all the BOM without any active version. By the way, this is a good example, too, for what we cannot do by means of Advanced Filter but quickly by coding a short job.


static void SIBOMwithNoActiveVersion(Args _args) { BOMTable bomTable; BOMVersion bomVersion; int nmbr, i; boolean printOnly = false; ; SetPrefix('BOMs without any active version'); Nmbr = 0; while select bomTable notexists join bomVersion where bomVersion.Active == NoYes::Yes && bomVersion.BOMId == bomTable.BOMId { nmbr++; info(strfmt("%1 %2, %3, %4, %5, %6, %7", nmbr, bomTable.BOMId, bomTable.Na…

Opening the table from x++ code

Opening the table from x++ codeThis code helps you to open the any Table from X++ code. Here is an example for SalesTable, just copy and paste this into a job you will get the table.

static void TableBrowser(Args _args)
{
SysTableBrowser sysTableBrowser = new SysTableBrowser();
;
//Browse the SalesTable table
sysTableBrowser.run(tablenum(SalesTable ));
}

How to run Client Batches on AX 2009

How to run Client Batches on AX 2009In AX 2009 the batch engine has been changed to run as a service.
The batch services do only process server batches they don't process client batches aynmore.
There might still be some situations where you would like to run client batches.
The following description explains how to do this.
Create a new batch group 'Client' which is used for client batches later.
(Administration -> Setup -> Batch groups) Add this batch group to an AOS acting as batch server.
(Administration -> Setup -> Server configuration)
This is needed to change the status from 'Waiting' to 'Ready' on the batch tasks and to 'Execute' on the batch jobs.
The batch server will not process any client batches.
Start the legacy batch client
(Basic -> Periodic -> Batch -> Processing) Select the new created batch group 'Client' and press 'OK'The client batch server will now process all client batches of the 'Client'…

Designate a batch server

Designate a batch server A batch server is an Application Object Server (AOS) instance that processes batch jobs. Batch jobs are used to run tasks, such as printing reports or posting journals, at a specified time and probably on a different computer.
The first AOS to be set up is automatically designated as a batch server. Use multiple batch servers to increase throughput and reduce the amount of time it takes to run batches.

When you set up a batch server, you can specify the times that it is available for batch processing. We recommend excluding a server from batch processing when it is busy with regular transaction processing. For example, you may have servers in different time zones. You can set server schedules so that each AOS is available for user traffic during the day and for batch traffic overnight.

For more information about batches, 
see the Applications and Business Processes Help, 
available from the Microsoft Dynamics AX Help menu. 

1. Click Administration > Setup

How to update vendor addresses in Dynamics AX

How to update vendor addresses in Dynamics AX 2009 Here is trick of X++ by which we can update the address for a vendor in Dynamics ax 2009,  below job is the possible answer and may helps.


static void UpdateVendAddressType(Args _args)
{
VendTable          vendTab; // Replace VendTable with CustTable when run this for customers.
DirPartyTable     dirPartyTab;
Address              addTab;
;
ttsbegin;
while select vendTab join dirPartyTab join forupdate addTab
                                                          where vendTab.PartyId        == dirPartyTab.PartyId
                                                             && addTab.AddrTableId == dirPartyTab.TableId
                                                            && addTab.AddrRecId     == dirPartyTab.RecId
{
      if(addTab.Name == ‘Birincil Adres’)
     {
        addTab.type = AddressType::Payment;
         addTab.update();
     }
}
ttscommit;
}

- Harry

Create Alert using X++ codes

Create Alert using X++ codes
Sometimes Infolog message is not sufficient enough for prompting information to users. It is possible to create alert message using code as an alternative. It is fairly simple to create alert message manually by just inserting a new record in EventTable where all the alert messages are stored. Below is a code snippet for creating alert using code in AX 2009.
Try following code......





staticvoidCreateAlertUsingCode(Args _args)
{
EventInbox          inbox;
;
inbox.initValue();
inbox.ShowPopup     = NoYes::Yes;
inbox.Subject       = "This is the Alert subject";
inbox.Message       = "This is the Alert message";
inbox.AlertedFor    = "This alert is just information no links are available";
inbox.SendEmail     = false;
inbox.UserId        = curuserid();
inbox.TypeId        = classnum(EventType);
inbox.AlertTableId  = tablenum(Address);
inbox.AlertFieldId  = fieldnum(Address, Name);
inbox.TypeTrigger   = EventTypeTrigger::FieldChanged;
inbox.CompanyI…

SysQueryRangeUtil class -Use method name as query criteria(Reports)

Image
SysQueryRangeUtil class - use method name as query criteriaThis is a cool new feature in AX 2009 - you can now use a method name instead of literal value in query criteria!
For example, if you run a report every month, previously you need to change the date criteria in each month you running the report  (ie.“01/06/2010..30/06/2010”,  “01/07/2010..31/07/2010”, etc).
Now you only need to enter(monthRange(0, 0))which will automatic return the correct first day and last day of the month.
For Example: - 


You can also refer to theSysQueryRangeUtilclass – there are a lot of useful methods such as dateRange(), currentEmployeeId(), etc. It’s also possible to create new method on this class for special purpose. But do this with caution.

- Harry

Finding all data sources in a form through Job

Image
Finding all data sources in a form through code Hi , Here is small trick to find the datasource in form. Open job node , and a new job and copy paste following code over there,.....
static void AllDataSourcesInForm(Args _args)
{
    Args args = new Args();
    FormRun fr;
    FormBuildDataSource formBuildDataSource;
    counter i;
    ;
    args.name("CustTable");   // its your FORM name
    fr = ClassFactory.formRunClass(args);
    for(i=1 ; i<=fr.form().dataSourceCount();i++)
    {
        formBuildDataSource = fr.form().dataSource(i);
        info(new DictTable(formBuildDataSource.table()).name());
    }
}



When you run this job you get all data source which is used in CustTable Form




















- Harry

Differences among reread(), refresh(),research()

Differences among reread(), refresh(),research()When working with Forms, commonly after opened the form we need to do some operations with existing data. In few cases we need to interact with data base again and again in order to do. For that we will use these methods. But some times its create confuse what exactly use of these methods, when should we call these methods and why, here is brief info these methods...

refresh() : this method will refresh the data in the data source cache. But it will not interact with the data base to fetch the new/updated record values. What ever values have fetched in the previous query will store in data source cache, this method will just refresh the data source cache only.

reread(): this method will interact with the data base and runs the query against the data base in order to fetch the new/updated record values. But this will not show the updated values in the form until calling the refresh method. that means it will update the data source form cach…

How to get the current database name in axapta

How to get the current database name in axaptaHere is a small trick to know the name of current data base in axapta. Axapta supports a class called SysSqlSystemInfo by using this class we can get the current database name... To do this just create a new job and write following code or you can copy paste from here also.

static void sqlSysName(Args _args)
{
    ;
    info(SysSQLSystemInfo::construct().getloginDatabase());
}

- Harry

Document Handling in Microsoft Dynamics AX

Image
Document Handling in Microsoft Dynamics AX 2009 and 2012



Document Handling is very useful to attach files related to AX data to forms. It’s possible to add data at any form. It is also useful to attache any reference document to any record in Form.
To use Document Handling you have to activate it by follow these steps...

To activate this feature follow the next steps:

1. Go to BasicSetupDocument management:


2. Setup Parameters:


Active directory is the default path where allocate the files to attach.
Check Use Active document tables has to be activated.


Number sequence to numerate the attachments.
3. Define Document types:


For each type it’s necessary define the location folder:


4. Select in which forms it’s possible to attach documents in Active document tables:




5. Now, we can attach documents in the above forms. For example in Employees form:




For this example, we are going to attach a Photo:


Select the photo and click open:



With the check Show file activated we can see the photo/document:


A…

Types of delete action

Types of delete actionIn Table node there is a sub node called "Delete Action". In axapta there is mainly three type of delete action. Each of them have their own specific use. Here is the simplest defination for each of them. CascadeA cascading deletion action will delete all records in the related table, where the foreign key is equivalent to the primary key of the current table. That is, deleting the parent record will also delete the child record(s) in the related table.
This cascading will take place whether the deletion is performed in code or directly by a user through the user interface.
RestrictedA restricting delete action will raise an error message if the user tries to delete a record, where records exist in the related table where the foreign key is equivalent to the primary key of the current table.
This error will only appear if the deletion is performed through the user interface. A deletion from X++ code will be allowed to proceed and will not be cascaded to …

Dynamics AX: Report Development Basics in AX 2012 - Drill Through Options

Hi Friends
I found a good article on Report Development in AX 2012. here is the link for it,
Dynamics AX: Report Development Basics in AX 2012 - Drill Through Options.
It’s useful for BI and Reporting concepts in AX 2012.
-Harry

Build numbers of Axapta

Build numbers of Microsoft Dynamics AxHi all,



Here theAxapta Versions, with a description of the version represented. in following tables all build version numbers are split into three parts.  First one is  the client version number , followed by the application version. Formatted  like: Build #client version/application version/localization vertsion e.g. #1951.7500/514-320/OP023-196 - for 3.0 KR2 client and 3.0 SP4 application.
Dynamics AX 2012
Build numberVersion6.0.852.782012 Beta6.0.947.02012 RTM6.0.947.612012 Cumulative Update 1 (CU1)6.0.947.2802012 Cumulative Update 2 (CU2)6.0.947.8622012 Feature Pack6.0.1108.6702012 Feature Pack with CU3




Dynamics AX 2009
Build numberVersionRPC interface version5.0.593.02009 RTM50444.0 (C50C.0000)5.0.593.4392009 Hotfix Rollup 1 (RU1)N/A5.0.593.6622009 Hotfix Rollup 2 (RU2)N/A5.0.593.8272009 Hotfix Rollup 3 (RU3)N/A5.0.593.10842009 Hotfix Rollup 4 (RU4)N/A5.0.593.12872009 Hotfix Rollup 5 (RU5)N/A5.0.593.14292009 Hotfix Rollup 6 (RU6)N/A5.0.1000.522009 SP…

Ebooks: List of free Microsoft E-books

How to Restore deleted sales order or purchase order

How to Restore deleted sales order or purchase order in AX 2009




Hi Frnds,
Some times fortunately or unfortunately user delete a record from Purchase Order OR Sales Order Forms,
and it can be drag you in a big problems, Here I am sharing a trick to restore these deleted Order records.
When ever a record is deleted from a Form, it sits in the void tables. These orders can be viewed from

AR -> Inquiries -> History -> Voided sales order or AP -> Inquiries -> History -> Voided Sales order.

AP -> Inquiries -> History -> Voided sales order or AP -> Inquiries -> History -> Voided Purchase order.

Now from this form you can only view the deleted orders but there is not option of restoring them.
Below are some sample code, you can use this to restore the voided orders.

Sales order restoration:
static void restoreDeletedSO(Args _args)
{
    SalesTableDelete    salesTableDelete;
    SalesLineDelete     salesLineDelete;
    SalesTable          salesTable;
    SalesLin…

AX 2012 – Data Migration Framework

AX 2012 – Data Migration Framework: Step-by-step setup Recently i found a great blog on Data Migration Framework, follow this link
AX 2012 – Data Migration Framework: Step-by-step setup
Its really help full for the step by step process of Data migration in AX 2009 to Ax 2012.
- Hary

How to send E-Mail In Microsoft Dynamics AX

Image
How to send E-mail In  AXThere are more than one way to send emails through Microsoft Dynamics AX system, using X++ code.
The most recommended way is to use the standard mail mechanism built in the system.
That way copies of any email you send will be save in the Email sending status form (based on tableSysOutgoingEmailTable) and you will be able to monitor and see status of sent emails:

http://theaxapta.blogspot.in/

(Administration -> Periodic -> E-mail processing -> Email sending status; Form: SysOutgoingEmailTable)





This mechanism based on a system table that contain the emails, and a batch job that scan that table and send the emails, one by one (with retries and status controlling).
This technique is very simple to use and therefore it has some disadvantages; you cannot add attachments or use advanced email properties (cc, bcc, priority flag, etc).
To use this mechanism, first you have to make sure you a SMTP server configured and running.
Go to
Administration -> Se…