Search This Blog

December 29, 2012

Import Opening Stock Balance into Dynamics AX

Import Opening Stock Balance into Dynamics AX

When 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 hand) to validate the X++ code.
The purpose to use Tag counting journal instead of Movement/Counting journal is we let the system to create the Lot ID when we post the Tag counting journal into Counting journal.

- Harry

December 07, 2012

Change company from the current company in X++ code

Change company from the current company in X++ code

If 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'.



December 05, 2012

Dynamics Ax Layers

 Dynamics Ax Layers

Dynamics 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 country to country.So such localization functionality
can be developed in GLS layer.

HFX HFX is an application object patch layer reserved by
Microsoft for future patching or other updates.

SL1, SL2,or SL3 A layer where the distributor can implement
vertical partner solutions.

BUS When a business partner creates their own generic solution,
their modifications are saved in the BUS layer and the top-
level application objects are used.

VAR Value Added Resellers (VAR) can make modifications or new
developments to the VAR layer as specified by the customers
or as a strategy of creating an industry-specific solution.
Such modifications are saved in the VAR layer.

CUS The supervisor or administrator of an end user installation
might want to make modifications that are generic to the
company. Such modifications are saved in the CUS (CUStomer)

USR End users might want to make their own modifications, such
as in their reports.These modifications are saved in the USR

December 04, 2012

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)
  1. Check AOS Service is running under an active domain user (domain\username)
  2. 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)
  3. You added the workflow website (http://servername:portnumber/DynamicsAXWorkflow50 for example) to the trusted sites in Internet Options of AOS server
  4. Run the following on the Workflow server:
  • After checking above points and then perform the following steps
  1. Start a command prompt.
  2. Locate and then change to the directory that contains the Adsutil.vbs file. (By default, this directory is C:\Inetpub\Adminscripts.)
  3. Type the following command, and then press ENTER: cscript adsutil.vbs set w3svc/NTAuthenticationProviders “NTLM”
  4. To verify that the NtAuthenticationProviders metabase property is set to NTLM, type the following command, and then press ENTER: cscript adsutil.vbs get w3svc/NTAuthenticationProviders
The output:
NTAuthenticationProviders       : (STRING) "NTLM"

After completing above procedure successfully then please take a restart of Ax and IIS service and then workflow infrastructure configuration wizard will work fine.


December 01, 2012

Open web pages from X++ code

Sending mail from AX using .NET Framework

Sometimes 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"", "");
    mailAddressTo = new  System.Net.Mail.MailAddress("","");
    strBody = "There is a email body";
    strSMTPServer = "MailServerName";
    // preparing mail with body, subject, from, to.
    mailMessage = new System.Net.Mail.MailMessage(mailAddressFrom, mailAddressTo);
    mailmessage.set_Subject("There is a email subject");
    attachementCollection = mailMessage.get_Attachments();

    strFileName = "C:\\path\\filename";
    // assert permision
    perm = new FileIOPermission(strFileName,'w');

    // attaching file to that email.
    attachment = new System.Net.Mail.Attachment(strFileName);
    smtpClient = new System.Net.Mail.SmtpClient(strSMTPServer);
    // release permision