Thursday, July 7, 2011

Upper- / lowercase oddity in AIF

Have you ever wondered why the name of batch id tag must start with a capital letter, i.e. , when using the InventDim table in an AIF service? The field in the table starts with a lowercase i.

Well, the reason is that AIF uses the names of the methods in the AX class (AxInventDim in this case) for the naming in the schema and of other artifacts it generates. On the AX class the method for this field is named “parmInventDimId”. So here the name starts with a capital letter.

Okay, that’s not really very odd and you could probably have figured this out just by making a qualified guess.

But then, why must the tag for the Serial Id start with a lower case s? The field name in the table starts with a lowercase s, and the method name is “parmInventSerialId”. So according to the logic above, the Serial Id tag should also start with an uppercase character.

This is where it gets interesting. In the \Classes\AxInternalBase\parmMethods method AX generates a list of fieldnames based on the parm methods of the AX class. The underlying class handing out the names is DictClass.
DictClass actually returns a wrong name, or at least not what you see in the AOT, for the parmInventSerialId method. It returns the name as parminventSerialId, which matches the casing of the table field and, voila, the tag can be named exactly as the table field.

Here is a job showing the names handed out by (Sys)DictClass:
static void AIF(Args _args)
    SysDictClass            dc = new SysDictClass(5790);
    Map                     methods;
    MapEnumerator           me;

    methods = dc.objectMethods2ClassId(true);
    me      = methods.getEnumerator();

    while (me.moveNext())
        if (substr(me.currentKey(),1,strlen('parm')) == 'parm')
            info (me.currentKey());

Sunday, July 3, 2011

Find your SID

If you restore the demodatabase for an AX 2012 image, you might need to know you SID in order to change your login in the AX database.

This vbs script displays your SID and copies it to your clipboard:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set objAccount = objWMIService.Get _
Wscript.Echo objAccount.SID

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd.exe /c echo " + objAccount.SID + " | clip", 0, TRUE

Wscript.Echo "Your SID is copied to the  clipboard"
You may need to change the values for the user account name and the domain.

And this is the script you can use in the database:
update userinfo
networkdomain = 'YourDomain',
networkalias = 'YourAlias',
SID = 'YourSID'
where ID = 'Admin'