Monday, December 26, 2011

Run AX client without using Load Balancer (though it setup already)

Hi,

It is  possible to configure/setup a client to open a dedicated connection to a specified AOS, although the AOs is member of a simple AOS cluster.


USE this command: AX32.exe -loadbalance=0 -aos2=<server name>:<port number>


Thanks.

Monday, December 19, 2011

Moving objects between Layers in AX

Hi,

I found a very good post to moving objects between two different layers in AX. You can find it here.

Hope its helps.

Thanks & Regards,
/Ashlesh

Sequence of all methods which are called when a RunBaseBatch process is executed


Hi,
I found one useful information from one of the blog. It might be useful to someone.
It can be handy to have detailed knowledge on the runbaseBatch class. In this tutorial I will explain the calling sequence of the RunBaseBatch class with a query (select button).
We will start this process with a static construct function that will force the runbaseBatch process to run on the server. 
In the left column of below table is shown the method name of the runbase batch and the location where it is running. The order of the lines in the table is also the order AX will execute the methods.
(Note: The runbase mechanism calls sometimes methods twice, these duplicate call are removed from this list.)

Server construct
Our constructor will execute the new method
Server new

Server prompt

Server unpack

Server showdialog

Server pack

Client new
Reconstruct the class on the AX client
Client unpack
Get the values from the previous run
Client canGoBatch
Do we need to show the batch tab page
Client prompt

Client showdialog
Do we need to show dialog
Client caption
Set the caption of the dialog
Client queryRun
Get the query object (if exist)
Client showQueryValues
Do we need to query values on the general tab page of the dialog
Client showQuerySelectButton
Do we need to query select button on the dialog
Client showDefaultButton
Do we need default button
Client showClearButton
Do we need clear button
Client dialog
Build your dialog (don’t remove super otherwise you don’t see the batch tab page
Client dialogPostRun
Used to make additional modification to the dialog (field High), set overload methods

Finally our dialog appears on the screen.
Next we press the OK button. The next methods of the runbaseBatch will be executed:

Client getFromDialog
We get the values from the dialog , don’t remove super otherwise batch and select info is gone
Client validate
Check if all dialog values are valid
Client pack
Store the values in the SysLastValue table
Server unpack
Readout the values from the SysLastValue table
Server canGoBatch
Check if we have to run in batch
Server run
Run the process (can be from batch process)


Regards,
/Ashlesh

Thursday, December 15, 2011

Override dialog controls event on dynamic dialog


Hi,

I found a useful thing from the dev. cook book ax 2009.

To override the dialog fields (controls) event from the dynamically created dialogs.

Usage of dialogSelectCtrl() sometimes might appear a bit limited as this method is only
invoked when the dialog control loses its focus. No other events can be controlled, and it can
become messy if more controls needs to be processed. Actually, this method is called from
the selectControl() of the form, which is used as a base for the dialog.

As mentioned earlier, dialogs created using the Dialog class are actually forms, which are
dynamically created during runtime. So in order to extend event handling functionality on
dialogs, we should utilize form event handling features.

The Dialog class does not provide direct access to form event handling functions, but we can
easily access the form object within the dialog. Although we cannot create the usual event
handling methods on runtime form controls, we can override this behavior. Let's modify the
previous example to include more events. We will add an event on the second tab page, which
is triggered once the page is activated. First, we have to override the dialogPostRun()
method on the Class1 class:

public void dialogPostRun(DialogRunbase dialog)
{;
dialog.formRun().controlMethodOverload(true);
dialog.formRun().controlMethodOverloadObject(this);  //this refers the current class object
super(dialog);
}

Here, we enable event overriding on the form after it is fully created and is ready for
displaying on the screen. We also pass the CustSelect object as argument for the
controlMethodOverloadObject() to make sure that form "knows" where overridden
events are located.

Next, we have to create the method that overrides the tab page event:

void TabPg_2_pageActivated()
{;
info('Tab page activated');
}

The method name consists of the control name and event name joined with an underscore.
But before creating such methods, we first have to get the name of the runtime control. This
is because the dialog form is created dynamically, and Dynamics AX defines control names
automatically without allowing the user to choose them. In this example, I have temporary
added the following code to the bottom of dialog(), which displayed the name of the

Details tab page control when the class was executed:

info(tabDetails.name());

Now, run the class again, and select the Details tab page. The message should be displayed
in the Infolog.

Hope it helps.

Regards,
/Ashlesh

Monday, December 5, 2011

Tools | Options will crash AX 2009

Hi,
Recently i am facing a crashing problem with AX 2009 while I am going to Files > Tools > Options, it will crash the AX 2009 client application.

Solution: Follow below steps to overcome this issue.
1. go to Administrator > Setup > Checklist > Installation Checklist
2. click on Compile Application to fully complile the application.

After completing the above step you will be able to open the Options form.

Hope it helps.

Thanks,
/Ashlesh

Sunday, December 4, 2011

How to capture the modified field in runbasebatch

Hi,

RunBase.dialogSelectCtrl Method
 
When using the dialog class for dialog, this method is called whenever a control is selected. 
 
To enable this callback, the allowUpdateOnSelectCtrl method must have been set true.
 
You have to add to the dialog() method, after the super's call add the line

dialog.allowUpdateOnSelectCtrl(true);

and then each time a dialog method is entered the method dialogSelectCtrl() is executed, you can control there the modified
field.

If you have any doubt about the behaviour have a look at the class BOMHierarchyCheckJob.
 
Hope it helps.
 
Regards,
/Ashlesh 

Monday, November 28, 2011

Error while firming the planned order: "Lot ID for the production not specified"

Hi,

Sometimes it is possible to facing the error "LotID for the production is not specified." while firming the planned orders from 'Master Planning > Planned orders details'.

Solution:
Please make sure the number sequence settings for the Production must be setup as "Automatically". The above error will come if it is selected as 'Manual'.

Hope this helps.

/Ashlesh

Thursday, November 24, 2011

Enterprise Portal: Failed to “Generate Proxies”

Hi,

While creating proxy class from AOT and after generating proxy for the same from Tools->Dev. Tools-> Web Dev. -> Proxy, using Generate Proxy form. It gives the errors "ClrObject static method invocation error."

To overcome this,
1. go to AOT->Classes->SysEPDeployment->createDevWebsiteProxyDir().
2. find and comment below line,

dir = epSharepointAdmin.GetAppCodeDirectoryFromSiteId(guid2str(epGlobalParam.DevelopmentSiteId));
3. replace it with (locate your virtual directory app_code folder)
dir = "C:\\Inetpub\\wwwroot\\wss\\VirtualDirectories\\sharepoint80\\App_Code"; 
4. Save the class file.

Now, again run the 'Generate Proxy' class. 
 
It works fine.

Thanks.
/Ashlesh

Tuesday, November 22, 2011

EP tools are not visible in VS 2008 toolbox


Hi,

Recently i faced a problem that i can able to install EP development tools successfully. I can also select the Mciforost Dynamics Web project template while creating new Website. 
But not able to find any of the item of AX EP toolbox in the VS 2008 toolbox. So, after finding net a lot i found the below solution.


1. Got to choose item by right clicking on the toolbox in VS 2008.
2. in the .Net Framework component tab, browse for C:\Program Files\Microsoft Dynamics AX\50\Client\Bin\Microsoft.Dynamics.Framework.Portal.dll file.
3. Select all the items starts with AX*, and clickes ok.
4. restart the VS 2008.

Thats all. Hope it helps to someone.


Regards,
/Ashlesh

Thursday, November 17, 2011

AX 2009 - Enterprise Portal Documentation

Hi all,
I have installed and configured the Enterprise Portal for AX 2009 at our end. I faced troubles couple of times to successfully configured the EP on Windows Server 2008 R2 (64 bit) with Sharepoint Server 3.0 during that time. I found the web and got some very helpful documents on some blogs. I am sharing those with you. Hope it will reduce your time to install and configure the EP on  AX2009.

You can find the EP docs from below link:
AX 2009 - EP Documents

Thanks & Regards,
/Ashlesh

Monday, October 3, 2011

X++ code to validate only numbers in string

Hi,

Following job that illustrates the use of regular expressions in AX 2009 for validating only numbers exists in the string.

static void TextBuffer_regularExpression(Args _args)
{

    TextBuffer txt = new TextBuffer();
    str msg = "98797897";
    ;

    txt.setText(msg);
    txt.regularExpressions(true);   // activate regular expr in search

     // Regular expression to validate only digits
     if (txt.find("^[0-9]+$"))
    {
        info("string contains only numbers");
    }

}

Regards,
/Ashlesh

Thursday, September 29, 2011

Set Prefix in Infolog message

Use below code to set the grouping prefix for the different kind of errors in a single infolog message. 
 
static void TestJob(Args _args)
{
    setPrefix("Main");
    info("Prefix\tInfo1");
    info("Prefix\tInfo2");
    info("Prefix2\tInfo3");
    info("Prefix\tInfo3");
}
 
Regards,
/Ashlesh 

Sunday, September 11, 2011

TFS error while startup AX 2009 clinent after installing VS 2010

If AX 2009 is configured with TFS 2008 and later you have installed VS 2010 on the same system, you will get the below error.

Could not load file or assembly 'Microsoft.TeamFoundation.VersionControl.Client, Version=9.0.0.0,Culture=neutral,PublicKeyToken = b03f5f7f11d50a3a' or one of its dependencies, The system cannot find the file specified.

Follow the steps to resolve this error:
1. Install VS 2008 Team Explorer.
2. Install VS 2008 SP1.
3. Install VS 2008 Team Explorer SP1.

This is because AX uses the 9.0.XXX version of TFS-Client assembly.

Regards,
/Ashlesh

Friday, September 9, 2011

More about AX File extensions


Some notes on AX File extensions :

Most of these files are located in the application folder (AX 2009):
C:\Program Files\Microsoft Dynamics AX\50\Application\Appl\[your_application]
The extensions have 3 characters:
The first character indicates the owner of the file:
a: application
k: kernel
The second character indicates the content of the file:l: label
o: object
t: text
d: developer documentation
h: help
And the third character indicates the type of file:d: data
i: index
c: cache
t: temporary
Using this logic, we can easily name all file extensions, and understand their purpose.In the application folder:
ALD extension: Application Label Data files
These files contain the labels and label comments for a specific language of a label file.
ALC extension: Application Label Cache files
These files contain the application label cache. These files can be deleted when the AOS is stopped.
ALI extension: Application Label Index files
The .ali files contain an index to the .ald files. These files can be deleted when the AOS is stopped.
ALT extension: Application Label Temporary files
These files contain new labels before they are committed to the .ald file.
AOI extension: Application Object Index file
The AOI file contains an index to the AOD files. You can delete this file when the AOS is stopped. Be sure to delete this when you have copied layers from one AX installation to an other.
ADD extension: Application Developer Documentation Data files
These files contain the documentation that is found under the Application Developer Documentation node. These files are localized, just like label files.
ADI extension: Application Developer Documentation Index files
This is the index to the ADD file.
AHD extension: Application Help Data files
The AHD file contains the documentation aimed at the end user. In the AOT, this is found in the “Application Documentation” node.
AHI extension: Application Help Index files
This is the index to the AHD file.
AOD extension: Application Object Data file
This is the ‘AX layer file’, each of these files represents one layer.
KHD extension: Kernel Help Documentation files
These files contain the kernel help documentation you can find in the AOT in the tree node System Documentation.
KHI extension: Kernel Help Index files
The KHI file is the index to the Kernel Help file.
Located in Server/bin:
KTD extension: Kernel Text Data file
This file contains system text strings. These are used in the interface of AX and for system messages.
KTI extension: Kernel Text Index file
This is the index to the KTD file.
Client side (not following the naming logic):
AUC extension: Application Unicode Object Cache file (as from AX 4.0)
This file is created on the client side, and is used to improve performance by caching AX objects. When you are in the situation where an AX client keeps using ‘old code’, or where something works on one client and not on the other, removing the AUC file might be the solution.
You can find this file in the directory C:\Documents and Settings\[USERNAME]\Local Settings\Application Data for xp, or C:\Users\USERNAME\AppData\Local for vista.
AOC extension: Axapta Object Cache file (Untill Axapta 3)
This is the ‘old’ version of the AUC file but serves the same purpose.


Regards,
/Ashlesh

Wednesday, September 7, 2011

Layers in Dynamics Ax

The manner in which layers were used in the old Ax was pretty clear, we had

SYS, SYP Used by the core system
GLS, GLP Used by the initial added modules which were bought in ( CRM from Hands Norway, Product builder from Aston (now Tectura) HRM from Circle Capital, Shop Floor from Thy Data Center ).
LOS, LOP Used by some countries to add functionality ( US EDI connector, Germany Cost Accounting from Circon )
DIS, DIP Used by most countries for localisation
BUS,BUP Used initially by partners freely then only by invitation in an early version of IBI (Industry Builder Initiative)
VAR,VAP Used by the partners to put their code in
CUS,CUP Reserved for the customer
USR,USP Reserved for the customers

/Ashlesh

Moving a whole project from USR layer to BUS layer

If you do not have to pay attention to data in tables (theses will be
deleted in this solution), i think you can do the following:

1. Logon in the Layer where the customisation is made (i.e. USR Layer).
2. Export the whole development project into a .xpo file (without ID's!).
3. Delete the all customisations/objects belongs to the development projekt
in the current layer.
4. Logoff
5. Logon in the Layer where you will move your customisation to (i.e. BUS
Layer).
6. Import the .xpo file (see also step 2).
7. Check that your customisation has no error (compile it) and that it's
working correctly.

But, keep in mind, that all objects get new ID's when you import them into
the new Layer.
As far as i know that cause problems if you have:

1. Data in the tables or fields which are getting new Id's
2. If you build references between between tables over table id and recid.
3. If you use "hardcoded" ID Refernces between object. I.e. if you use a
hardcoded table id insted of tablenum().
Regards,
/Ashlesh

Thursday, July 21, 2011

Focus a particular lookup record in LookUpform

Hi,

Focus on the particular record in the opened lookup.

args.lookupRecord(reasonTable::find(this.text()));

Thanks,
/Ashlesh

Tuesday, July 19, 2011

Open a form in AX Workspacewindow only

Hi,
Using below lines before super() call in init() of the form, the form will open in AX Workspacewindow only.

if(this.form().design().windowType()==FormWindowType::Standard)
this.form().design().windowType(FormWindowType::Workspace);

Thanks.

Tuesday, July 5, 2011

Filtering different file types in a browse dialog

Hi,

to filter the different types of files in a browse dialog,

public Object dialog()
{
    DialogRunbase       dialog = super();
    #AviFiles
    #Excel

    dialogFilename = dialog.addField(typeId(FilenameOpen));
    dialog.filenameLookupFilter(["@SYS28576",#XLSX,"@SYS100852","*.csv"]);
    dialog.filenameLookupTitle("Upload from EXCEL/CSV");
    dialogFilename.value(filename);
    return dialog;
}

To build a LIKE query in AX 2009

Hi,

to build a QueryRun object same as LIKE SQL query.

void createQuery()
{
    Query query = new Query();
    QueryRun queryRun;
    BOMTable bt;
    InventTable it;
    BOMId bomId;
    ;
    it = InventTable::find('ELB002');
    query.addDataSource(tableNum(BOMTable)).addRange(fieldNum(BOMTable, BOMId)).value(strfmt("%1-*",it.ItemId));
    queryRun = new QueryRun(query);
   
    bomId = strfmt("%1-%2",it.ItemId, SysQuery::countTotal(queryRun)+1);
    info(bomId);
}

Also review for more details QueryRanges

Hope it helps.

Thanks,
/Ashlesh

To find MAX, MIN, COUNT of any table in AX 2009

Hi,
Below is the code snipet to find out the MAX value of a particular field in a particular table.
static void MaxValueTest(Args _args)
{
    str maxValue(TableId tableId, FieldId fieldId)
    {
        QueryRun qr = new QueryRun(new Query());
        qr.query().addDataSource(tableId).addSelectionField(fieldId, SelectionField::Max);
        return qr.next() ? any2str(qr.get(tableId).(fieldId)) : '';
    }
    ;
    info(maxValue(tableNum(BOMTable), fieldNum(BOMTable,BOMId)));
}

In the above example the "SlecttionField" has the mulitple static filed which can give you more choices.

Thanks,
/Ashlesh

Wednesday, June 29, 2011

Very useful link for Form Development in AX 2009

Hi,

Really nice aritcle for the Form Development.

Form Developement Resources


Thanks,

Implement "Go to the Main Table" on the field

Hi,
To implement the "Go to the Main Table" functionality on any lookup field :

Override the jumpRef() method of the control,

public void jumpRef()
{
CustTable custTable;
Args args;
MenuFunction menuFunction;
;
custTable = CustTable::find(this.text());
if (!custTable)
{
return;
}
args = new Args();
args.caller(element);
args.record(custTable);
menuFunction = new MenuFunction(
menuitemdisplaystr(CustTable),
MenuItemType::Display);
menuFunction.run(args);
}

Thanks.

To count total records from the customized query

Hi,
Below is the code to count the total no. of records using QueryRun.

        q = new Query();
        qbd = q.addDataSource(TableNum(BOMVersion));
        qbr = qbd.addRange(FieldNum(BOMVersion, ItemId));
        qbr.value("ELB008");
        qr = new QueryRun(q);
        info(strfmt("Total Record: %1", SysQuery::countTotal(qr)));

Thanks,
/Ashlesh

Sunday, June 26, 2011

To create a Directory Path (X++)

Hi,

To create a particular Dicetory path using X++, follow below code steps:

protected boolean createDirectoryPath(FilePath _path)
{
    int ptr;
    ;
    try
    {
        //First check for the passed path exits or not
        if (winAPI::folderExists(_path))
        {
            return true;
        }

        _path = strLRTrim(_path);

        if (substr(_path,strlen(_path),1) != '\\') //Adding backslash gives a more simple while-loop!
        {
            _path += '\\';
        }

        //MKU: enables creation of UNC paths, by detecting which folder already exists (backwards).
        ptr = strLen(_path);
        ptr = strfind(_path, '\\', ptr, -ptr);
        while(!WinAPI::folderExists(substr(_path,1,ptr)))
        {
            ptr = strfind(_path, '\\', ptr -1 , -ptr);
        }
        // ptr now points to last existing folder in the path.
        //MKU: end

        while (ptr)
        {
            WinAPI::createDirectory(substr(_path, 1, ptr));
            if (!WinAPI::folderExists(substr(_path, 1, ptr)))
            {
                break;
            }
            ptr = strfind(_path, '\\', ptr + 1, strlen(_path));
        }

        return WinAPI::folderExists(_path);
    }
    catch
    {
        info('@WML75'); //Item image is not created.
        return false;
    }
}

Thanks,
/Ashlesh

Ax Directory Path X++

 Hi,
 Below are the useful paths.

To get Axapta directory path:

xinfo::directory(directorytype::Temp);
xinfo::directory(directorytype::appl);

To get local directory temp path:
WinApi::getTempPath()

Thanks.

Thursday, June 23, 2011

Find the difference between two Times

Hi,

Using below code find the difference between two time values,

static void DateTimeDifference(Args _args)
{
    UTCDateTime abcdatetime;
    ;
    sleep(5000);
    info(strfmt("Difference: %1",DateTimeUtil::getDifference(DateTimeUtil::getSystemDateTime(),abcdatetime)));
}

To Create a new company - Demo data in AX 4.1 and above

Hi,
I found a very good article from 'dynamicsaxaptatraining' website. I have copied the link for that below.

How to create demo data for a new company in AX?

This also contains the link to download the Demo Data.

Thanks,
/Ashlesh

Tuesday, June 21, 2011

Set the Dialog in Center of the screen

To set the dialog to center of the screen,

static void dialogShowAtCenter(Args _args)
{
Dialog dlg = new Dialog("Dialog");
;

dlg.addText("This dialog is shown in the center of the screen.");

dlg.dialogForm().form().design().left(44, 4); //center
dlg.dialogForm().form().design().top(220, 3); //center

dlg.run();
}

Monday, June 6, 2011

To store an image to as container data type in a table

Hi,

To store the image to a continer datatype in a table a sample code unit is as below:
display Bitmap bitmap()
{
   Bitmap bitmap;
   Bindata     binData = new BinData();

if (binData.loadFile('c:\\1.bmp'))
   {
       bitmap = binData.getData();
   }
   return bitmap;
}
 
Thanks,
/Ashlesh 

Tuesday, May 24, 2011

To pad the string in AX 2009

Hi,
To pad the special char to end/start of the string follow below function,
client server public static str StrLFix(
    str _str, 
    int _length, 
   [char _char])
 
And 
client server public static str StrRFix(
    str _str, 
    int _length, 
   [char _char]) 
 
Regards,
/Ashlesh 

Tuesday, April 5, 2011

Hide the content pane in Ax 2009

Execute below code to hide the content pane in AX 2009.

static void hideContentPane(Args _args)
{
#WinApi
HWND contentPane = WinApi::findWindowEx(WinAPI::findWindowEx(infolog.hWnd(), 0, 'MDIClient', ''),0,'ContentFrame','' );
;
if (contentPane)
WinApi::ShowWindow(contentPane, #SW_HIDE);
//Change to #SW_SHOWNORMAL when you want it back
}



/Ashlesh

Get the current CallStack in X++

Hi,

You can get the current call stack in X++ code anywhere in any module.

Container con;
str coninfo;
con = xSession::xppCallStack();
coninfo = con2str(con);
info(coninfo);

Hope it helps.

/Ashlesh

Monday, February 14, 2011

Lables with linebreaks

I found an interesting comment for Box example as below from one of the blog.

Labels can contain line breaks. For example, “Text1\nText2” (let it has ID @LBL1).

However, if you’ll try to display this label “as is”, the result will be not expected:
Box::info("@LBL1");
Gives







To get the expected message with line break strFmtLB() method should be used:
Box::info(strFmtLB("@LBL1"));
Gives 








/Ashlesh

Tuesday, January 25, 2011

To restart the AX using X++

Hi,
To restart the AX using X++ code, follow below steps.

//Restart AX
infolog.shutDown(true);  //Shutdown the AX
WINAPI::shellExecute("ax32.exe");  //Start the AX

Hope it helps you.

Regards,
/Ashlesh

Import xpo files in AX using command line


Hi,
I found the below useful details from some blog.

To execute something in Axapta from outside you can use two ways:
1. Use Business Connector -- this was covered in this group already
2. Use startupcmd parameter when starting ax32.exe

ax32.exe -internal=NOVCS -lazyclassloading -startupcmd=autorun_MyFile.xml

where the XML would be like this:
<?xml version="1.0" encoding="utf-8"?>
<AxaptaAutoRun version="4.0" logFile="C:\MyFile.log">
<!-- what to do? -->
</AxaptaAutoRun>

This XML doesn't really contain anything and thus it wouldn't do anything
special. If you want to import an XPO you can use ImportXpo element and to
run a class you use Run element.

<?xml version="1.0" encoding="utf-8"?>
<AxaptaAutoRun version="4.0" logFile="C:\MyFile.log">
<XpoImport file="C:\Class_MyClass.xpo" />
<Run type="class" name="MyClass" method="main" />
</AxaptaAutoRun>

Hope this is useful to someone.

Regards,
/Ashlesh