Wednesday, 29 June 2016

NEW DYNAMICS AX Build Error: X++ project cannot be built. Another build is in progress

Hi there,

Just a quick tip here on the Build error.  Have encountered the situation where I could not perform the build neither test the changes I did, the Visual Studio was throwing the above error.  It was a multi-developer environment, thought another developer was actually performing the Build, but that was not the case.  Tried kicking out the other users, restart Visual Studio, still the problem was there.

Then comes the typical way, RESTART the Server (VM) that resolved the issue!  Simple thing, but you could save some time digging the mud which does not yield anything.

Cheers,
Abdul

Friday, 17 June 2016

Manipulating Nested Containers

Hi there,

I am sure all the X++ developers at some point might have come across with a situation to use Container type data, and so do I.  At times, a container type field is required for the table, or required for handling the business logic, etc.  The functions around Containers are also very minimal and easy to use.  Here, I am going to discuss about the Nested containers where the situation demands you to store containers within a container.

For example,
    Simple container:     container c = ["blue", "yellow", "red"];
    Mixed container:      container mixed = ["blue", 10.00, 125, true];
    Nested container:     container nested = [c, mixed];

Say, we have a nested container now and we want to retrieve the values from it.  You may want to write something like below:

int i;
container temp;
;
for (i = 1; i <= conlen(nested); i++)
{
    temp = conpeek(nested, i);
    print con2str(temp);  // you can always loop thru it and retrieve each element
}

Adding values to the container is not always straight forward.  For example, you may not simply assign values to the container like c = ["blue", "yellow", "red"];  instead, you might want to fetch the color information from a different source (may be from a table), and add the elements to the container on the go like below:
        while select Color
         {
                c += Color.Name;
                         OR
                 c = conIns(c, i, Color.Name); 
//initialize i to 1 and increment within the loop for the next position.
          }

Have you ever tried to figure out what is the difference between these two approaches.  When can we use "+=" and when can we use "conIns()".
Generally, X++ developers use "+=" approach, because it is easy to write, no need to manage a counter to identify the position, etc.

What if I tell you "+=" approach won't work in certain situation whereas "conIns()" would.  Yes.  Look at the below code:

What do you think the output of the below program would be:

static void ContainerDemo(Args _args)
{
    container baseContainer;
    container childContainer;    
    int i;
    ;
    
    childContainer = ["Vendor Account", "Customer Account"];
    baseContainer += childContainer;    
    
    childContainer = ["V0001", "C0001"];
    baseContainer += childContainer;            
    
    for (i = 1; i <= conLen(baseContainer); i++)
    {
        childContainer = conPeek(baseContainer, i);
        print con2Str(childContainer);
    }
    
    pause;
    
}

It would print,
Vendor Account,Customer Account
V0001,C0001

WRONG!!!  The above program in AX 2012 R2 would throw a run-time error as below on the line: childContainer = conPeek(baseContainer, i);

Error executing code: Wrong argument types in variable assignment.

What's wrong with that line?  Frankly, it is correct and this is the typical way to retrieve values from the container.  But why this error?

Because the values stored inside the "baseContainer" is also a container or set of containers.  This kind of situation demands the usage of "conIns()". Yes, we need to use "conIns()", and here is the modified code:

static void ContainerDemo(Args _args)
{
    container baseContainer;
    container childContainer;    
    int i;
    ;
    
    childContainer = ["Vendor Account", "Customer Account"];
    baseContainer = conins(baseContainer, 1, childContainer);    
    
    childContainer = ["V0001", "C0001"];
     baseContainer = conins(baseContainer, 2, childContainer);          
    
    for (i = 1; i <= conLen(baseContainer); i++)
    {
        childContainer = conPeek(baseContainer, i);
        print con2Str(childContainer);
    }
    
    pause;
    
}

Here is the output,
Vendor Account,Customer Account
V0001,C0001

This the minor thing but very useful to know.

Cheers,
Abdul


Tuesday, 7 June 2016

Changing Dashboard Banner in NEW DYNAMICS AX (AX7)

Hi there,

Here is one cosmetic stuff - Changing the Banner!

What is Banner in AX7?  It is what you see in the Default Dashboard










Have you ever tried changing this banner to something else specific to your organization?  Yes, it is very much possible.  Also, this banner is Legal Entity specific.  For example, you can have a banner for the legal entity USMF, and a different banner for US01, etc.  And, you guessed it right, we have to make this change at Organization administration > Organizations > Legal entities.

There is a fast tab in Legal entities page called "Images" which will help changing the banners.















Click Edit to change it to Edit mode.
Change the Dashboard Company Image Type to "Banner".
Click "Change" under "DASHBOARD IMAGE" group and browse an image.  The new image will be reflected in the legal entities page.

Refresh the page, and there you go, your new banner will be displayed in the Dashboard on that legal entity.

Note:  I have not seen any limitation on the dimension of the banner.  For example, I tried with my profile picture and is still working but I could just see only my hair :).  

Cheers!