Monday, February 28, 2011

Another way of reading in Active Directory from within Dynamics Ax

Some posts ago we talked about reading in the Active Directory from Ax.  We used some CLR for that.  But as it is so many times with Ax, Ax has it's own routines readily available to do the job as well.  Let's look at the class xAxaptaUserManager and xAxaptaUserDetails.

Some examples:

How to get the SID from AD for a domain user:

static void GetSID(Args _args)
{ 
   xAxaptaUserManager xUsrMgr = new xAxaptaUserManager();
   ;
   info(xUsrMgr.getUserSid('youruserid','youraddomain'));
}

Note: Remember you can user the field networkalias from table UserInfo to do a conversion from Ax user id to the domain user id.

You can use this class for various purposes. Also for checking a password.

How to validate the system password in AD from within Ax

static void CheckPassword(Args _args)
{   
    xAxaptaUserManager  xUsrMgr = new xAxaptaUserManager();
    ;
    if(xUsrMgr.validatePassword('youruserid','youraddomain','yourpassword'))
        info('Password correct');
    else
        error('Password incorrect');
}

We could get some more information from the AD regarding the user by using class xAxaptaUserDetails.

How to get the user name from AD for a user

static void GetADUserName(Args _args)
{   
    xAxaptaUserManager  xUsrMgr = new xAxaptaUserManager();
    xAxaptaUserDetails  xUsrDet;
    ;
    xUsrDet = xUsrMgr.getDomainUser('youraddomain','youruserid');
    
    if(xUsrDet)
        info(xUsrDet.getUserName(0));
}

How to get the email address from AD for a user

static void GetADEmailAddress(Args _args)
{   
    xAxaptaUserManager  xUsrMgr = new xAxaptaUserManager();
    xAxaptaUserDetails  xUsrDet;
    ;
    xUsrDet = xUsrMgr.getDomainUser('youraddomain','youruserid');
    
    if(xUsrDet)
        info(xUsrDet.getUserMail(0));
}

So the AD holds no secrets for one that knows Ax...

Friday, February 25, 2011

How to get the first and the last day of a month

When working with dates for a range in a SQL select statement, you may be in need for the first and the last day of a certain month.  What at first seems a bit difficult to calculate (not all the months have the same number of days for example), is pretty easy to accomplish with the right tools.

 
The first day of a month

 
You can fool around with things like mkdate, so something like this:

 
static void FirstOfMonth(Args _args)
{ 
   TransDate TransDate=today();
   TransDate FirstOfMth;
   ;

   FirstOfMth=mkdate(1,mthofyr(TransDate),year(TransDate));

   info(date2str(FirstOfMth,123,2,2,2,2,4));
} 
 
But there is a readily available function in the Global class, albeit somewhat hidden: DateStartMth.
 
So your code could read like this:
 
static void FirstOfMonth(Args _args) 
{
   TransDate TransDate=today();
   TransDate FirstOfMth;
   ;
   FirstOfMth=DateStartMth(TransDate);

   info(date2str(FirstOfMth,123,2,2,2,2,4));
} 

 
The last day of a month

 
Just like with the first day of a month, we have a function that will do the job for us: endmth
This function calculates the last date in the month of the date specified.

static void LastOfMonth(Args _args)
{
   TransDate TransDate=today();
   TransDate LastOfMth;
   ;

   LastOfMth=endmth(TransDate);

   info(date2str(LastOfMth,123,2,2,2,2,4));
}
 
You may want to check out following functions as well, with some other date functionality:

Wednesday, February 9, 2011

A small detail to keep in mind when copying a production database to a test/development environment

Over on the net you can find tips here and there on how to use a database from a live production environment and set it up as a database for a test or development environment.
A small detail that doesn't always get the right attention in such procedures is the cache file of Ax.  I had a post about this earlier on in my blog.  What it comes down to is that the filename of the cache file of the Ax client is derived from the GUID in the table SysSqmSettings

If you simply copy the database from live to development or test, the GUID in this table is copied as well.  If an Ax client connects to your AOS, it will use this value for deciding on the cache file.  Now if you have multiple databases having the same GUID in this table, you get multiple different Ax instances linked to the same cache file.  So one cache file for different environments.  Needless to say this will give you strange or unexpected behaviour when running the Ax client.

So it always is a good idea to reset the GUID in table SysSqmSettings after the restore of your live production database into some test or development environment.

Monday, February 7, 2011

Will you be upgrading to Dynamics Ax 2012 immediately?

Last post learned us that a big part of the Ax community is still not on the most recent release of Ax, despite its availability for 2,5 years now.  Ax has lots of stuff to help you upgrading (code compare tools, upgrade scripts, a 100+ page manual, ...), Microsoft allows you to even skip major versions in between upgrading.  But even then, a lot of people didn't make the jump. 

With the new release in sight, will they be left behind?  Are there enough reasons now to pull them over the line?  Can the costs be accounted for?  Does it generate only a positive impact for business and IT?
Face it, even with all the tools to help you during the actual upgrade, it still remains a meticulous piece of work, testing your endurance.  A project comparable with that of an original implementation (redesign yes/no?).  Every business has to do it's homework and list up the pro's and con's.

And what about you?  Will you go for the instant upgrade?  Can't wait to get your hands on all the new stuff?
Or are you waiting for market feedback, people that share their upgrade experiences regarding Ax?  Or do you believe that SP1 is soon to follow, providing more stability and improved functionality? 

Take the poll on the right!  Let us know!

Sunday, February 6, 2011

What version of Dynamics Ax are you using?

The next version of Ax has a name: Dynamics Ax 2012. No official release date yet, but it will be available Q3 of 2011.

(So the version numbering is consistent with Microsofts policy on this.)

With all the news about this release, I tought it would be fun to see what versions are being used out there. Did users already manage the upgrade to 2009, the most recent release to date?


So I had this little poll up on my blog. Nothing fancy, just a simple question: Which version of Ax are you on?



Now the number of participants in the poll is way too low to make any real conclusions, but it sure gives a nice idea.
Here are the numbers:






As you can see from the graph, approx. 65% is using the currently latest release of Ax, version 2009.

And consequently 35% is still working on an older version of Ax. Actually, this means that more then 35% never upgraded, even 2,5 years after general availability of Ax 2009. I say more, because in the 65% mentioned using Ax 2009 also new customers are included, customers who bought and started out with version 2009.

This gives Microsoft food for thought. And they did think about it, seeing already all the information about the upgrade enhancements in the new release. It means developers our there have access to new tools to help them out for the upgrade process. But with all the technology enhancements in general out there, it also means there is more to upgrade, more options to consider. (What about things like reports, BI modifications, ...)

You could skip one major version upgrading from 3.0 to 2009, so without installing 4.0. At the time, Microsoft punctuated that would be a one time offer. But hearing the news about Ax 2012, again you have the option to skip one major release, this being 2012. That sure is good news for 35% of the Ax people out there...

Next up: A new poll for Dynamics Ax 2012!