Wednesday, September 16, 2015

AX 2012 - How to intercept the AX Shutdown?

Hi All

How to block the AX Shutdown?

Easy, go through the Info class, canShutdown method.
So, insert an IF condition before the Return and ask to the user if is sure to close AX.

That's it!

Monday, September 7, 2015

AX 2012 – Have a list of the SSRS Reports to a specific Layer using Model tables



Hi Guys


Below a quick code to have the list of SSRS Reports created or modified to a specific Layer or Model.


Run this against the Model DB

By Layer will be :


use ModelDb


SELECT a.name, a.origin, a.axid, a.parentid, b.modelid, c.LayerId, d.name, e.name


  FROM ModelElement a


  join ModelElementData b


  on a.ElementHandle = b.ElementHandle


  join model c


  on b.ModelId = c.id


  join layer d


  on d.Id = c.LayerId


  join ModelManifest e


  on e.ModelId = b.modelid


  where a.elementType = 85


  and   c.LayerId <> 0


  and   d.name = 'VAR'





By Model will be :



use ModelDb


SELECT a.name, a.origin, a.axid, a.parentid, b.modelid, c.LayerId, d.name, e.name


  FROM ModelElement a


  join ModelElementData b


  on a.ElementHandle = b.ElementHandle


  join model c


  on b.ModelId = c.id


  join layer d


  on d.Id = c.LayerId


  join ModelManifest e


  on e.ModelId = b.modelid


  where a.elementType = 85


  and   c.LayerId <> 0


  and   e.name = 'ModelName'



Enjoy!

Wednesday, July 22, 2015

TFS - How to view and export the Changeset ?

Hi All
 
Below an easy way to view and export the TFS Changeset.
 
1.      Open the Source Control Explorer

2.      Go through "View History" from your Team Project

3.      Go to the bottom of the list

4.      Select all records

5.      Copy all

6.      Open Excel and paste the selection
Now you are able to analyze the data using the power of Excel.
 
That's it!
Stay tuned!

Sunday, July 19, 2015

Microsoft Dynamics AX 7 Launch Portal

Hi All


Microsoft have published the Launch Site for Dynamics AX 7 with WPC Sessions, Launch Events, Sales & Marketing, etc.


Microsoft Dynamics ‘AX 7’ Launch Portal


Stay Tuned!

Sunday, April 19, 2015

AX 2012 - How to fix Data Dictionary ( SqlDictionary ) issue after importing a Model, ModelStore or during the TFS BUILD Process

Hi All
 
During the development phase, many tasks are made on the Data Dictionary.
Create tables and fields, rename or delete them.
So, often the Synchronization process failed.
To avoid this issue, you can create a process that fix the SqlDictionary Table.
During the time, I created many Jobs.
 
The main started from the Martin post with the following changes :
1.       To avoid the duplicate key, I read the fields starting from the last one.
2.       For each table, I delete first the fields from the SqlDictionary that no more exist on AOT
 
If you use the TFS Build, before the Synchronization you can run the above job.
The same during the Modelstore transportation scripts.
Here the code :

    Dictionary dictionary = new Dictionary();
    SysDictTable dictTable;
    DictField dictField;
    TableId tableId;
    FieldId fieldId;
    Counter fieldCnt;
    SqlDictionary sqlDictionaryTable;
    SqlDictionary sqlDictionaryField;
    setPrefix("Update of data dictionary IDs");
    tableId = dictionary.tableNext(0);
    ttsbegin;
    while (tableId)
    {
        dictTable = new SysDictTable(tableId);
        setPrefix(dictTable.name());
        if ( dictTable.isSystemTable()
        ||   dictTable.isView()
        ||   dicttable.isTempDb()
        ||   dictTable.isTmp()
           )
        {
            tableId = dictionary.tableNext(tableId);
            continue;
        }
        ///////////
        //Finds table in SqlDictionary by name in AOT, if ID was changed.
        //Empty field ID represents a table.
        select sqlDictionaryTable
            where sqlDictionaryTable.name == dictTable.name()
            && sqlDictionaryTable.fieldId == 0
            && sqlDictionaryTable.tabId != dictTable.id();
        if (sqlDictionaryTable)
        {
            //Updates table ID in SqlDictionary
            if (ReleaseUpdateDB::changeTableId(
                sqlDictionaryTable.tabId,
                dictTable.id(),
                dictTable.name()))
            {
                info(strFmt("Table ID changed (%1 -> %2)", sqlDictionaryTable.tabId, dictTable.id()));
            }
        }
        ////////////
        // Delete Fields that no more exists in AOT
        while select forUpdate sqlDictionaryTable
            where sqlDictionaryTable.tabId == dictTable.id()
            &&    sqlDictionaryTable.fieldId
        {
            If ( ! dictTable.fieldName2Id( sqlDictionaryTable.name ) )
            {
                sqlDictionaryTable.delete();
            }
        }
        ////////////
        //fieldId = dictTable.fieldNext(0);
        fieldCnt = dictTable.fieldCnt();
        fieldId = dictTable.fieldCnt2Id(fieldCnt);
        //For all fields in table
        while (fieldCnt)
        {
            dictField = dictTable.fieldObject(fieldId);
            if (dictField.isSql() && !dictField.isSystem())
            {
                //Finds fields in SqlDictionary by name and compares IDs
                select sqlDictionaryField
                    where sqlDictionaryField.tabId == dictTable.id()
                    && sqlDictionaryField.name == dictField.name()
                    && sqlDictionaryField.fieldId != 0
                    && sqlDictionaryField.fieldId != dictField.id();
                if (sqlDictionaryField)
                {
                    //Updates field ID in SqlDictionary
                    if (ReleaseUpdateDB::changeFieldId(
                        dictTable.id(),
                        sqlDictionaryField.fieldId,
                        dictField.id(),
                        dictTable.name(),
                        dictField.name()))
                    {
                        info(strFmt("Field %1 - ID changed (%2 -> %3)",
                            dictField.name(),
                            sqlDictionaryField.fieldId,
                            dictField.id()));
                    }
                }
            }
            //fieldId = dictTable.fieldNext(fieldId);
            fieldCnt--;
            fieldId = dictTable.fieldCnt2Id(fieldCnt);
        }
        tableId = dictionary.tableNext(tableId);
    }
    ttscommit;

Thursday, April 16, 2015

Change the TITLE of the AX Main Window

Hi


When you open Dynamics AX, the main windows is a form.
So, if you want to change the Title, the code is very easy :
WinAPI::setWindowText( infolog.hWnd(), "Magic AX")
If you want to manage automatically,is enough move this code to the startupPost method of the Info class.
If you want trigger this code for every workspace, you have to move the code on the workspaceWindowCreated method of the Info class, like this :
WinAPI::setWindowText( _hWnd, "Magic AX");
Thas'it!
Stay Tuned!


Sunday, April 12, 2015

Second MVP Award on Dynamics AX

Hi All

Is a pleasure announce the renewal to the Microsoft MVP on Dynamics AX!

Although very busy with my daily activities I am happy to share my knowledge with others in the world.
Become an MVP mean enter in a big family, get in touch with other fantastic guys also in other expertise and finally get in touch with Microsoft!
With Yammer, direct message, etc. I have the opportunity to reach the best people in the world that can help me in my daily activities.

Finally, a big thanks to the others MVP on Dynamics AX, always available.
You can find and see them to the follow LINK

Look through this Video to resume my reaction in Office... -))

Enjoy with Dynamics AX!