Thursday, June 23, 2011

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