Monday 27 October 2014

how to locate AUC file in AX 2012

The location of the file depends on your operating system. Under Windows XP the file will be located under your Local Settings\Application Data folder. Usually, this is as follows:
C:\Documents and Settings\%USERNAME%\Local Settings\Application Data
Under Windows 7 and Windows Vista the file will be located under:
%USERPROFILE%\AppData\Local

 cache file is stored together with the user profile information. And as so it's location varies according to the operating system version used.

You can find it in following folder:
Windows XP and Windows 2003
C:\Documents and Settings\%username%\Local Settings\Application Data

Windows Vista, Windows 7 and Windows 2008
C:\Users\%username%\AppData\Local

Thursday 23 October 2014

basic C# programming structure

A C# program basically consists of the following parts:

Namespace declaration
 A class
 Class methods
 Class attributes
 A Main method
 Statements & Expressions
 Comments

**********************************

using System;
namespace HelloWorldApplication
{
 class HelloWorld
 {
 static void Main(string[] args)
 {
 /* my first program in C# */
 Console.WriteLine("Hello World");
 Console.ReadKey();
 }
 }
}

******************************************


Let us look at various parts of the above program:
 The first line of the program using System; - the using keyword is used to include the System namespace in 
the program. A program generally has multiple using statements.
 The next line has the namespace declaration. A namespace is a collection of classes. The
HelloWorldApplication namespace contains the class HelloWorld.
 The next line has a class declaration, the class HelloWorld contains the data and method definitions that your 
program uses. Classes generally would contain more than one method. Methods define the behavior of the class. 
However, the HelloWorld class has only one method Main.
 The next line defines the Main method, which is the entry point for all C# programs. The Main method states 
what the class will do when executed
 The next line /*...*/ will be ignored by the compiler and it has been put to add additional comments in the program.
 The Main method specifies its behavior with the statement Console.WriteLine("Hello World");
WriteLine is a method of the Console class defined in the System namespace. This statement causes the 
message "Hello, World!" to be displayed on the screen.
 The last line Console.ReadKey(); is for the VS.NET Users. This makes the program wait for a key press and it 
prevents the screen from running and closing quickly when the program is launched from Visual Studio .NET.
It's worth to note the following points:
 C# is case sensitive.
 All statements and expression must end with a semicolon (;).
 The program execution starts at the Main method.
 Unlike Java, file name could be different from the class name

Monday 20 October 2014

get AX username in a X++ job

create a new job and paste the code there:

                     UserInfo                    userinfo;

                   Select name from userinfo where userinfo.id == curUserId();

                    Box::info("Welcome"+userinfo.name);

Friday 17 October 2014

Filter Records in Form by using Combo Box in AX 2012

SQL throws an error message like cannot select a record in form/table,The sql databse has issued an error.

please do the following steps:

)According to the error message either the location C:\Program Files\Microsoft Dynamics AX\40\Server\UAT\Log\ is not accessible or the account is not having sufficient permission.

have you tried changing the default location of the SQL log file and check if you are experiencing the error messages or not.

2)You have to restart the sql server reporting services on the server. For this type services.msc on run on your server and enter then restart the sql server reporting services. This may serve your purpose.

3)Run a full database synch on all of your tables.
Admin > Periodic > SQL administration > Table Actions > Synchronize database

*******************************************************************************************
 when the data in a test instance is refreshed from the production environment and the definition of a table in the test environment has been altered. In this case you should be able to fix the problem by resynchronizing. This process will modify the SQL table to match the definition in AX.

To resynchronize, go to System Administration>Periodic>SQL administration. I always select “All Tables” and under table actions click on “Check Synchronize.” This will take a few minutes to run. During the process you may get warnings. Read the warnings carefully and consider the implications before you tell it to continue. 

Thursday 16 October 2014

advantages and disadvantages of indexes in ax 2012



The advantages of indexes are as follows:
  • Their use in queries usually results in much better performance.
  • They make it possible to quickly retrieve (fetch) data.
  • They can be used for sorting. A post-fetch-sort operation can be eliminated.
  • Unique indexes guarantee uniquely identifiable records in the database.
The disadvantages of indexes are as follows:
  • They decrease performance on inserts, updates, and deletes.
  • They take up space (this increases with the number of fields used and the length of the fields).
  • Some databases will monocase values in fields that are indexed.
You should only create indexes when they are actually needed.
Take care not to add an index on something that has already been indexed. If you need a more detailed index, you can add fields to an existing index as long as it is not a unique index.
please go through for more info :

Map diagram in ax 2012

mapping is use to link the similar fields of diffrent fields of similar type in diffrent tables

Sequence of methods in the FORM level in AX


Method calls in the form level while
1. Opening the Form.
2. Creating/Updating/Deleting the record in the Form.
3. Closing the Form.
Sequence of Methods calls while opening the Form
Form --- init ()
Form --- Datasource --- init ()
Form --- run ()
Form --- Datasource --- execute Query ()
Form --- Datasource --- active ()

Sequence of Methods calls while closing the Form
Form --- canClose ()
Form --- close ()

Sequence of Methods calls while creating the record in the Form
Form --- Datasource --- create ()
Form --- Datasource --- initValue ()
Table --- initValue ()
Form --- Datasource --- active ()

Sequence of Method calls while saving the record in the Form
Form --- Datasource --- ValidateWrite ()
Table --- ValidateWrite ()
Form --- Datasource --- write ()
Table --- insert ()

Sequence of Method calls while deleting the record in the Form
Form --- Datasource --- validatedelete ()
Table --- validatedelete ()
Table --- delete ()
Form --- Datasource --- active ()

Sequence of Methods calls while modifying the fields in the Form
Table --- validateField ()
Table --- modifiedField ()

List vs Set, Container and Map

Containers:Containers are dynamic and have no limits. They can contain elements of
almost all data types: boolean, integer, real, date, string, container,
arrays, tables, and extended data types. However, objects may not be stored
in containers.
Containers in AX are used very often. It’s easy to work with them. But…
data in containers are stored sequentially, and thus retrieved sequentially.
This means that containers provide slower data access if you are working with
_large numbers_ of records. In case of large numbers of records use temporary
tables.
List:
Lists are structures that may contain any number of elements that are
accessed sequentially. Lists may contain values of any X++ type. All the
values in the list must be of __the same__(this is the main difference
between lists and containers) type, given in the creation of the list. The
implementation of lists is such that traversal of the list elements is __very
fast.
Take a look for example at class Dialog addControl() method.
There controls are stored in ctrls List.
Map:
A map is a data type that associates one (key) value with another value [An
analog - a small table in memory with two fields: Keys, Values]. Both the key
and value values may be of any valid X++ type, including objects. The types
of the key and the value are given in the declaration of the map. The
implementation of maps is such that access to the values is _very fast_.
Don’t confuse map X++ types with Map objects in AOT, wich are used for
mapping tables with similar structures of fields
-
Set:
The functionality of Sets is similar with list.  A Set is just an unordered list of items, while a list of items held by a Map
are indexed via via a key.
Take look at
\Classes\sysLabel\LabelModuleId().
In any case use Search in AOT\Classes or Forms and look how are used
different X++ types in AX.

error while creating sales order(FormRun (data source) has no valid runable code in ...")

When you try to create a slaes order in ax  the you might get a error like " FormRun (data source) has no valid runable code in method"

In such scenerio please compile the salestable form

then you might get a set of error and warning please remove the errors the form will work fine 

or else delete the sales table form in AOT and then the system automatically will remove the error.

How to schedule the Full CIL

please see this link,

it is very nice feature:

http://patrikluca.blogspot.in/2013/12/schedule-full-cil-compile.html

white papers in AX



please follow the given below link to get white papers :

http://www.khwai.com/content/view/108/25/

Wednesday 15 October 2014

best practices related to the if-else statement and switch statement

A few recommended best practices related to the if-else statement and switch
statement are as follows:


Always use positive logic e.g. write if (true) rather than if (! false).
Prefer switch statement rather than multiple if-else statements.
Always end a case with a break or return or throw statement unless a fall
through mechanism is intentionally used. When a fall through mechanism
is used a comment should be given like //fall through so that it is clear to
every reader.

technical documentation on Ax 3.0

Hi guys,

If any one need ant technical document on Ax 3.0 please send me mail at rohitsinghbatchu@hotmail.com  or paste your mail address here

http://dynamicsuser.net/forums/t/45803.aspx

I will send an email attachment to you.

registration for AUX summit 2014

Please follow this link for registration:

https://www.regonline.com/Register/Checkin.aspx?EventID=1316706

checkfailed in ax 2012

checkfailed can be used for precisely while executing the validation method to return a error message instead of throw error mressage

use like :ret = checkFailed(“enter the vaule between 40 to 50.”);

or
public boolean validate()
{
    boolean ret;

    ret = super();

    if(!tablename)
    {
        return checkFailed("it does not have any vaulue ");  
    }

    return ret;
}


thow message is used in the business logic where if we encounter some error messages then the execution should be stopped.

In validation we should never use throw error message as it will  stop the further validation steps.

suggestion for developers

1)if you find any trouble in coding don't simply google the stuff, first look out  in AX, by doing this you will learn the functionality of Ax from the business prospective and get your job done same time
2)always follow the best pratise it will make sure that your coding will not give any warnings.

Tuesday 14 October 2014

when to choose temp table or in memory tables for SSRS reports

When you are developing SSRS reports, we don't pay attention while choosing temp table or in memory


when we know that we have less data in report we can choose in memory table

when we are aware that there are lot of datas choose temp table instead in memory tables.

  In a developer's point of view, temporary tables store data in the same way as normal physical tables, except that the data is automatically dropped when no longer required.

     Prior to Dynamics AX 2012 versions, only one type of temporary table was available. In AX 2012, however, the Temporary property on tables was replaced with a new property: TableType, which has three possible values:
·         Regular - a standard physical table
·         InMemory - the type of temporary table which existed in the previous versions of Dynamics Ax. Such tables are held in memory and written to a local disk file once they grow beyond a certain point
·         TempDB - a new option in Ax 2012. They are "physical" temporary tables held in the SQL Server database.

AX 2012: Creating parm methods automatically

static void createParmMethod(Args _args)
{
    #AOT

    ClassName className = classStr(MyClass);

    TreeNode classDeclarationTreeNode;
    TreeNode classTreeNode;
    TreeNode parmMethodNode;

    Source classDeclaration;

    System.Text.RegularExpressions.MatchCollection mcVariables;
    System.Text.RegularExpressions.Match mVariable;
    int matchCount;
    int matchIdx;

    System.Text.RegularExpressions.GroupCollection gcVariableDeclaration;
    System.Text.RegularExpressions.Group gVariableDeclarationPart;

    str variableType;
    str variableName;

    str pattern = ' (?[a-zA-Z0-9_]+) (?[a-zA-Z0-9_]+);';

    Source parmMethodBody;

    classTreeNode = TreeNode::findNode(strFmt(@"%1\%2", #ClassesPath, className));

    classDeclarationTreeNode = TreeNode::findNode(
        strFmt(@"%1\%2\ClassDeclaration",
        #ClassesPath,
        className));

    classDeclaration = classDeclarationTreeNode.AOTgetSource();

    mcVariables = System.Text.RegularExpressions.Regex::Matches(
        classDeclaration,
        pattern,
        System.Text.RegularExpressions.RegexOptions::Singleline);
    matchCount = CLRInterop::getAnyTypeForObject(mcVariables.get_Count());

    for (matchIdx = 0; matchIdx < matchCount; matchIdx++)
    {
        mVariable = mcVariables.get_Item(matchIdx);
        gcVariableDeclaration = mVariable.get_Groups();

        gVariableDeclarationPart = gcVariableDeclaration.get_Item('VarType');
        variableType = gVariableDeclarationPart.get_Value();

        gVariableDeclarationPart = gcVariableDeclaration.get_Item('VarName');
        variableName = gVariableDeclarationPart.get_Value();

        parmMethodBody = new xppSource().parmMethod(variableType, variableName);

        parmMethodNode = classTreeNode.AOTadd('method1');
        parmMethodNode.AOTsetSource(parmMethodBody);
        classTreeNode.AOTsave();
    }

    classTreeNode.AOTcompile();
}
for more info please look :http://dynamicsaxinsight.wordpress.com/2014/10/10/ax-2012-creating-parm-methods-automatically/

 

Monday 13 October 2014

how to set the default company when ax opens every time


Default settings can allow a user to open the same company every time the launch AX. Navigate to File > Tools > Options > General Tab > Options FastTab – Start company accounts and select desired company from the dropdown.


for more info   check :

http://www.stoneridgesoftware.com/default-settings-to-improve-the-microsoft-dynamics-ax-user-experience-3/

to get unique values in a customized field look up

SysTableLookup    sysTableLookup;
  QueryBuildDataSource    queryBuildDataSource;
  QueryBuildRange         queryBuildRange;
  Query query = new Query();
  sysTableLookup = new SysTableLookup();
  sysTableLookup = SysTableLookup::newParameters(tableNum(tablename), this);
  sysTableLookup.addLookupfield(fieldNum(tablename,fieldname));


   //create the query datasource
  queryBuildDataSource = query.addDataSource(tablenum(tablename));
  queryBuildRange = queryBuildDataSource.addRange(fieldnum(GTFS_PayrollEmpPeriodHeader, fieldname1));
  queryBuildRange.value(tablename.fieldname1);
     queryBuildDataSource.addSortField(fieldnumtablename,fieldname));
    queryBuildDataSource.addOrderByField(fieldnumtablename,fieldname));
    SysTableLookup.parmUseLookupValue(false);
    queryBuildDataSource.orderMode(OrderMode::GroupBy);

  sysTableLookup.parmQuery(query);
  sysTableLookup.performFormLookup();

AX interview Questions

1. what is model store and model and their diffrence....
2.diffrence between temp table vs in memory when to use what????

Problem solving in Dynamics AX – A quick check-list

Sometimes, when developing, AX doesn’t work as expected, or behaves weird.

Here are some of the things you can try if you run out of ideas, below are some of steps.
Try to Reproduce: You probably already did, but make sure you can reproduce the problem. If it only occurred once, it’s not a problem.
Check your code again:Check your code carefully for errors, and maybe ask a colleague’s opinion.
Compile : Your project might contain compile errors, so compile it to be sure.
Close the debugger: Sometimes, when the debugger is active, AX will keep executing ‘old’ code. Close the debugger to make sure the latest code is executing.
Compile forward :When you have modified a class that is inherited by other classes, you might want to compile forward this class.
Synchronize data dictionary : You may have made changes to application objects that haven’t been synchronized with the database. Open the AOT, right click on the Data Dictionary node and choose Synchronize.
Restart AX client : Simple as that, close the AX client and start it again.
Reset usage data : Go to options screen (AX button > Extra > Options) and click the Usage Data button. Click reset to remove this data.
Check the application event log for clues : Open the event viewer on the AOS to see if the AOS service has logged something in it. Messages here can help you a great deal. You can also check the event log on the database server or your client pc.
Use Internet Search Engine : If you receive an error, just copy and paste it in Internet Search engine. Most likely you are not the only one having that problem.
Check your AX client version: You might for example be connecting to a SP1 application with an SP0 client. You can check this in the about screen: AX button > Help > About. The kernel version indicates the client version, below that is the application version.
Refresh AOD, Dictionary and Data : You can flush cashed information using three option in the Tools > Development tools menu: refresh AOD, refresh Dictionary and refresh Data. This can be useful when you just imported an xpo file, or when you are developing for the enterprise portal.
Delete AUC file : The application Unicode object cache file, if there is one, is located at [DRIVE]:\Documents and Settings\[USERNAME]\Local Settings\Application Data for xp, or [DRIVE]:\Users\USERNAME\AppData\Local for vista. Delete this file while the AX client is closed.
Check if other users are having the same problem : Knowing whether you are the only one that’s having that problem or if it’s a general problem is a big step towards solving the problem. For example, if you alone have the problem, restarting the AOS probably won’t solve it, but removing usage data might.
Check security settings : When only some users have a problem, big changes are that it has something to do with security settings. Security can be set up from Administration > Setup > Security, on the Permissions tab.
Check configuration key setup : Some features of AX won’t work if a configuration key is disabled, be aware of this.
Full compile : Open the AOT, right click the AOT node and select compile.
Restart AOS : Sometimes restarting the AOS solves your problem just fine. If you can, it’s worth the try as this doesn’t take long.
Remove .aoi file : When the AOS is stopped, you can delete the .aoi file from the application files. This file will be rebuilt when the AOS starts.
Check the Log files : There are few logs which are very important to know.
  • AIF Exception Log
  • Windows Event Log
  • endpoint's logs
The AIF exception logs can be accessed in Dynamics AX by going to
Basic | Periodic| Application Integration Framework | Exceptions
Files with client trace are located in Client’s log directory. In default configuration it is set to either
 [Drive]:\Users\Public\Microsoft\Dynamics Ax\Log\
or  [Drive]:\Document and Settings\All Users\Microsoft\Dynamics Ax\Log\
or [Drive]:\Program Files\Microsoft Dynamics AX\6.0\Client\Bin\DynamicsInfologTrace.log

Conclusion

There are differences in Dynamics AX 2009 and Dynamics AX 2012, differences in the modules, user interface, reports and many other features. The X++ MorphX reports are completely deprecated and recomended to use SSRS, The BizTalk adapter has been deprecated and replaced with WCF-compliant Services. As a developer what I see is the scope for development aspect using with Visual Studio.Net has eventually increased in MS Dynamics AX 2012. The goal of this article was to provide some useful tips and help the developers and encourage newbies to get familiarity on Dynamics AX.
There could be similar works found from other sources. How ever the objective of this article is to address the tips & solutions and few differences in Dynamics AX versions. To the best of knowledge know such work was found for matching/reference.

new way to calulate the number of day in any month of the year

static void Job30(Args _args)
{

    System.DateTime     now;
    str                 getDateStr;
    int n;
    ;
   
    //now = System.DateTime::DaysInMonth(2000,6);
   
     n = System.DateTime::DaysInMonth(2000,6);
   // getDateStr = now.ToString();
   // info("It is now : "+getDateStr);
    info(strFmt("%1",n));


}


please try this and see the diffrence:

Wednesday 8 October 2014

to get number of temp table in AOT

static void TmpTablesList(Args _args)
{
     DictTable dictTable;
     Dictionary dict = new Dictionary();
     int i;
     container names;
     #ResAppl
    
    for (i=1; i<=dict.tableCnt(); i++)
    {
            dictTable = new DictTable(dict.tableCnt2Id(i));
            if ( dictTable.isTmp()) 
            {
                names += dictTable.name();
            }
        
    }
    conView(names);
}

How to delete Label Files from AX 2012


Here are the steps to delete Label Files from AX 2012:

  • Create a new model. You could call it "LabelsBeGone".
  • Open the AOT and move the Label File(s) you want to get rid of to the new model.
  • Close AX and stop the AOS.
  • Use AXUtil to delete the new model.
  • Delete the label files from the server folder; C:\Program Files\Microsoft Dynamics AX\60\Server\...\bin\Application\Appl\Standard
  • Start the AOS.
  • Skip the upgrade wizard.

AX and mobile intergration

Here you can find the  AX and mobile intergation information


http://www.dynamicsanywhere.com/dynamicsanywhere/ax-anywhere

intercompany PO multiple product receipt by x++

public void processStampICPO(PackingSlipId _deliveryNote,                             Transdate _deliverydate,                             ...