Tuesday, December 13, 2011

Dates In An Extended Query Range

Let's say we need to range all the BOM versions that are active as of today. For this purpose we can use an extended range in the query.

{
    QueryBuildRange qbr;
    ;
    if(!_args.record())
        return;
    // there is an active caller!
    switch (_args.record().TableId)
    {
        case tablenum(InventTable):
            inventTable = element.args().record();
            this.query().dataSourceTable(tablenum(InventTable)).addRange(fieldnum(InventTable, ItemId)).value(inventTable.ItemId);
            qbr = this.query().dataSourceTable(tablenum(BOMVersion)).addRange(fieldnum(BOMVersion, RecId));
            qbr.value('(fromDate <= '+date2StrXpp(today())+') && (toDate >= '+date2StrXpp(today())+')');
            break;

The final SQL query will look like this (a fragment):


= BOMVersion.ItemId AND ((Active = 1)) AND (((fromDate <=13\12\2011) && (toDate >= 13\12\2011))) JOIN * FROM BOM(BOM_1) ORDER BY BOM.LineNum ASC ON BOMVersion.BOMId = BOM.BOMId

The idea was taken from the AX forum (in Russian).

Monday, October 31, 2011

Two tricks about stopping AX service via PowerShell

Generally speaking, it is true for all Windows services but my particular example is about stopping Microsoft Dynamics AX service (AOS) via PowerShell.

As recommended in Deploying customizations across Microsoft Dynamics AX environments white paper, before importing a metadata model store into the target environment, one must stop all AOS instances in it.

First trick is on how to provide the correct name of the service supposed to be stopped.



If you try to use the service name you see in Services, you will fail.

PS C:\Windows\system> Set-Service -name AOS60$01 -status stopped
Set-Service : Service AOS60 was not found on computer '.'.
At line:1 char:12
+ Set-Service  -name AOS60$01 -status stopped + CategoryInfo : ObjectNotFound: (.:String) [Set-Service], Invali dOperationException + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.C ommands.SetServiceCommand 

It is evident that the problem is in $ sign. To fix it you can simply quoted it with "'" (not with "!).
PS C:\Windows\system32> Set-Service -name 'AOS60$01' -status stopped

Unfortunately, this command does not work anyway because of an error:

Set-Service : Cannot stop service 'Microsoft Dynamics AX Object Server 6.0$01-a
x2012_std (AOS60$01)' because it is dependent on other services.
At line:1 char:12
+ Set-Service  -name 'AOS60$01' -status stopped + CategoryInfo : InvalidOperation: (System.ServiceProcess.Service Controller:ServiceController) [Set-Service], ServiceCommandException + FullyQualifiedErrorId : ServiceIsDependentOnNoForce,Microsoft.PowerShell .Commands.SetServiceCommand 

Nevertheless, you can stop the service as usual without any issue. I do not why it does not work but I would suggest that one use another commands to stop and start the service, namely:

PS C:\Windows\system32> Stop-Service 'AOS60$01'
WARNING: Waiting for service 'Microsoft Dynamics AX Object Server
6.0$01-ax2012_std (AOS60$01)' to finish stopping...

PS C:\Windows\system32> Start-Service 'AOS60$01'
WARNING: Waiting for service 'Microsoft Dynamics AX Object Server
6.0$01-ax2012_std (AOS60$01)' to finish starting...

It takes its time, be patient!




Thursday, September 29, 2011

visualize your resume!

I want to tell you about a new online project that allows you to visualize your resume. The project is still in beta version; nevertheless, it can perform some magic.

vizualize.me

It is well known that a picture paints a thousand words. It does not matter how many words are in your CV, but I am sure that you will be impressed as might be your eventual employer.

Right after signing up it is possible to import your profile directly from LinkedIn, de facto the most popular social network for professionals.

Now the project will generate your new good-looking resume automatically: by converting text into diagrams, schemes, maps, etc.



It is up to you what to include in each part of it.



Then you can ice the cake by choosing a theme you like or formatting text and diagrams.

Finally, you publish your new resume by one click.



Good luck in job landing!

Monday, July 11, 2011

Paint it black: How to color rows in Table form control

There a lot of answers on how to color grid lines and cells -- for example, this DisplayOption using from DAXGuy. However, my goal is to show how one can paint rows in Table form control. I use the standard tutorial form tutorial_Form_Table from AX2009.

On the table control, we need to change a bit EditControl method where we define in which color the current row will be painted. (Here, I provided you with a link where you can choose RGB colors to paint the hell at your own.)


// Color the active line in a table
FormControl editControl(int column, int row)
{
    #DEFINE.colorDarkTurkoise(112,147,219)                  // colors at your personal perception of hell
    #DEFINE.colorNeonBlue(77,77,255)
    #DEFINE.colorRosyBrown(255,193,193)
    #DEFINE.colorSaddleBrown(139,69,19)
    int oldStrColor = WinApi::RGB2int(#colorRosyBrown);     // colors for cells not in focus
    int oldIntColor = WinApi::RGB2int(#colorSaddleBrown);
    int newIntColor = WinApi::RGB2int(#colorNeonBlue);      // colors for the selected line
    int newStrColor = WinApi::RGB2int(#colorDarkTurkoise);
    ;
    // this is columns with int controls
    if ((column == 2) || (column == 4))
    {
        // not in the header
        if (row > 1)
        {
            // this is in the selected line
            if (row == table.row())
                intEdit.backgroundColor(newIntColor);
            else
                intEdit.backgroundColor(oldIntColor);
            return intEdit;
        }
        // this is the header
        else
        {
            if (row == table.row())
                editline.backgroundColor(newStrColor);
            else
                editline.backgroundColor(oldStrColor);
            return editline;
        }
    }
    else
    {
        if (row == table.row())
            editline.backgroundColor(newStrColor);
        else
            editline.backgroundColor(oldStrColor);
        return editline;
    }

}

So, when the user selects another row, all its controls change their color--it's your responsibility to return the correct form control: StringEdit, IntEdit and so on.

The second method where we redraw the form is activeCellChanged.


public void activeCellChanged()
{
    ;
    super();
    // do not forget to repaint the form!
    element.redraw();
}

Coloring can be realized much more complicated with different color scheme, calculated conditions etc.

Friday, May 13, 2011

Monday, May 2, 2011

How to find your object in AOT projects

This is a small but precious tool for AX developing.

Have you ever tried to find in which projects your objects are included? Yes, I have... Not so easy to search and look into each project.

Now, it is just a question of one click: this mighty LC Project Search will make the life easier. And good news, it is free. So, profit and enjoy!

There are three xpo-files with appropriate versions for AX 4.0, 2009, and 2012. (I have tested 2009 one). You can import it, then launch with the menu item, and this is ready to go.




Just type the name of any object you're looking for, optionally, you can choose the type of it, then press Search. Be patient, it takes some time to populate the result table.




Now, all projects contain the object are here.

Take a look at Loncar Technologies company web site: there you can get some more.

Friday, January 7, 2011

How to delete Pending Invoices

Still can't find how to kill your pending invoices? This new functionality made me crazy sometimes but now it's getting easier thanks to Raju Roy Chowdhurywho showed me this trick:

Go to
Accounts Payable --> Inquiries --> History --> Invoices

then find your invoices with Waiting status and delete them. Easy, eh?