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