table browser axapta

Upload: pjanssen2306

Post on 02-Jun-2018

251 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Table Browser axapta

    1/12

    Modify Dynamics AX Standard Excel Import to Include - Update existing records - rule

    doorMicrosoft Dynamics AX(Notities)op vrijdag 3 juni 2011 om 14:36

    Sometimes we need to import an excel file that contains existing and new records. With

    standard Dynamics AX 2009 you don't get an option (import rule) where you can specify

    ONLY import and update existing records. Below are standard AX excel import rules...

    To add a rule that says "Update existing records" only.

    Modify Enum SysDataExcelImportRuleto add a new element for update.

    Note: If you noticed I have inserted new Enum element with value 101, which is far away

    what Microsoft is using. It is a best practice to keep some difference between the enum values,

    so if Microsoft inserts new standard enum elements later then our custom enum element do

    not overlap with the standard. It helps when you upgrade your AX system in future.

    Modify Class SysDataImportExcel, method ImportData as stated below. Just add lines

    having related modification comments.

    1: switch (importRule)2: {3: //#N by Rahul Sharma on 19Apr2011 for

    RAH_ExcelImportRule_UpdateOnlyOption4: //added update only option5: case SysDataExcelImportRule::RAHUpdate :6: case SysDataExcelImportRule::InsertAndUpdate :7: selectForUpdate = true;8:9: case SysDataExcelImportRule::InsertNew :10: updCommon = this.recordExist(_dictTable, _curcommon,

    selectForUpdate);11: break;

    12: }

    http://www.facebook.com/DynamicsAXhttp://www.facebook.com/DynamicsAXhttp://www.facebook.com/DynamicsAXhttps://www.facebook.com/profile.php?id=154530571252588&sk=noteshttps://www.facebook.com/profile.php?id=154530571252588&sk=noteshttps://www.facebook.com/profile.php?id=154530571252588&sk=noteshttp://www.facebook.com/l.php?u=http://3.bp.blogspot.com/-98ZWZ3LSupo/Ta3kmNXe9rI/AAAAAAAABx8/CPMlO3APAKM/s1600/ImportExcelRulesEnum.jpg&h=uAQFiY7e4&s=1http://www.facebook.com/l.php?u=http://4.bp.blogspot.com/-Z9s-Z0tVFIQ/Ta3jaowiqoI/AAAAAAAABx4/EiaE1e5dpmU/s1600/ImportExcelRules.jpg&h=tAQEch0uu&s=1http://www.facebook.com/l.php?u=http://3.bp.blogspot.com/-98ZWZ3LSupo/Ta3kmNXe9rI/AAAAAAAABx8/CPMlO3APAKM/s1600/ImportExcelRulesEnum.jpg&h=uAQFiY7e4&s=1http://www.facebook.com/l.php?u=http://4.bp.blogspot.com/-Z9s-Z0tVFIQ/Ta3jaowiqoI/AAAAAAAABx4/EiaE1e5dpmU/s1600/ImportExcelRules.jpg&h=tAQEch0uu&s=1https://www.facebook.com/profile.php?id=154530571252588&sk=noteshttp://www.facebook.com/DynamicsAX
  • 8/10/2019 Table Browser axapta

    2/12

    1: if (updCommon.RecId)2: {3: //existing standard code4: }5: else6: {

    7: //#N by Rahul Sharma on 19Apr2011 forRAH_ExcelImportRule_UpdateOnlyOption8: //break if its a new record9: if (importRule == SysDataExcelImportRule::RAHUpdate)10: return false;11:12: selectForUpdate = false;13: updCommon = _curcommon;14: }

    After these small changes, you now should be able to import and update only existing records

    using standard AX excel import.

    You can download the AX Project from here.

    http://www.axaptapedia.com/DEV_SysTableBrowser

    http://www.axaptapedia.com/DEV_SysTableBrowserhttp://www.axaptapedia.com/DEV_SysTableBrowserhttp://4.bp.blogspot.com/-3JeUCatf8C8/Ta3nC5KFvaI/AAAAAAAAByA/ttq777HFTYM/s1600/ImportExcelRules2.jpghttp://www.axaptapedia.com/DEV_SysTableBrowser
  • 8/10/2019 Table Browser axapta

    3/12

    Dynamics Ax: Learn in doing -Ajitkumar's

    Don't learn to do.. But Learn in doing

    SATURDAY, OCTOBER 20, 2012

    Data dictionary and Tables (in Dynamics AX)Data Dictionarycan be defined as the data model for the Axapta application.The data in an Axapta installation is stored in a relational database. In short, this means that

    data is separated in tables to prevent redundant data occurring and relations are defined

    between the tables making it possible to gain access to the related data.

    An Axapta installation uses either a Microsoft SQL Server or an Oracle database forstoring data.

    Tables, views, fields and indexes are synchronized to the database when created,changed or deleted from Axapta. This definition of the data, is the only informationabout the data dictionary stored in the database, the actual data is physically storedwithin the Microsoft SQL Server or Oracle database

    Tip:

    Whenever we face any synchronization problems, the primary effective solution could be

    Running a Check/Synchronize in the SQL tool located in the main menu under

    Administration | Periodic | SQL Administration > Table actions ->

    Check/Synchronize buttonwill be useful.

    There are three main categories of Tables:

    1. Application Tables

    2. System Tables

    3. Temporary Tables

    Application Tables:

    These are user tables and are used to define and build the application modules. We can add a new field either to an Existing Table or to a New Table. If we add a new field to an existing table, then the new field is adding in the existing

    layer even though the modified table belongs to some other layer. (goes for all objectson a Table, except the delete actions) This is really an advantage while upgrading anapplication to a new release, because, we will only have to manually merge nodesmodified in more than one layer.

    System Tables:

    As the name suggests, these tables are created in the Kernel of the application. They contain

    information specific to operation of Axapta infrastructure.

    http://ajstudi0.blogspot.nl/http://ajstudi0.blogspot.nl/http://ajstudi0.blogspot.nl/http://ajstudi0.blogspot.nl/http://ajstudi0.blogspot.nl/http://ajstudi0.blogspot.nl/
  • 8/10/2019 Table Browser axapta

    4/12

    System tables are non-changeable. You cannot modify the data model of a systemtable.

    System tables can be found in the AOT under the nodeSystemDocumentation/Table. Their purpose is to handle tasks such as keeping the database in sync with the

    application, handling licensing and user informationNote: The system table SysLastValue stores usage data. This table is frequently used in the

    application as it stores the last user settings for an object. But we might not see SysLastValue

    declared from code, as the table is wrapped in the runbase framework or used by the class

    xSysLastValue.

    Temporary Tables:

    The table property Temporary determines whether a table is temporary or not. And

    any application table can be set to temporary by setting the table property Temporaryto Yes.Caution: Setting a table containing data to temporary will cause existing data to bedeleted.

    A temporary table contains no data and is not synchronized to the database. Atemporary table may be used as any normal table in joins and selects.

    To easily locate temporary tables in the AOT, all temporary tables are prefixed withTmp*.

    The major reason for using temporary tables is for the sorting of data. You might haveto present data using a specific sort in a form/report which cannot be accomplishedusing a select statement or a query. Instead you can create a temporary table, byfetching data from the tables and insert according to the sort requirement. As long the

    temporary table is in scope, the temporary table will contain data.The content of a temporary table is stored in the file system as a temporary file.

    It will initially take a longer time to load the form data-sourced with temporary tables,but the application will perform much faster once the data is loaded and therebyprovide a more user-friendly system.

    Table Browser:

    Table browser is quite handy to get an overview of the data in the table. Table browser can be accessed by right-clicking on any table in the data dictionary

    (Add-Ins > Table browser) The table browser is created using a standard form which is called SysTableBrowser. This can be used for creating/updating records in a table for Testing purposes. Whereas, this cannot be used as an application user tool, because, data entered

    through table browser will be only validated upon the business logic mentioned in theTable scripts and not the business logic that could possibly be mentioned in the Formmethods. So Only the form which has been created within Axapta must be used to keyin live data for tables.

    http://ajstudi0.blogspot.nl/search?updated-min=2013-01-01T00:00:00%2B05:30&updated-

    max=2014-01-01T00:00:00%2B05:30&max-results=21

    http://ajstudi0.blogspot.nl/search?updated-min=2013-01-01T00:00:00%2B05:30&updated-max=2014-01-01T00:00:00%2B05:30&max-results=21http://ajstudi0.blogspot.nl/search?updated-min=2013-01-01T00:00:00%2B05:30&updated-max=2014-01-01T00:00:00%2B05:30&max-results=21http://ajstudi0.blogspot.nl/search?updated-min=2013-01-01T00:00:00%2B05:30&updated-max=2014-01-01T00:00:00%2B05:30&max-results=21http://ajstudi0.blogspot.nl/search?updated-min=2013-01-01T00:00:00%2B05:30&updated-max=2014-01-01T00:00:00%2B05:30&max-results=21http://ajstudi0.blogspot.nl/search?updated-min=2013-01-01T00:00:00%2B05:30&updated-max=2014-01-01T00:00:00%2B05:30&max-results=21
  • 8/10/2019 Table Browser axapta

    5/12

    Form browser for Dynamics Ax

    Tables

    In this example I am going to illustrate, a Formwill be displayed, from the Tables Context

    Menu. The form will show the records from selected table. We can call this form as Form

    Browserfor tables.

    I had created the following Classfor displaying the Formbrowser from AOT-Tables.

    class PSShowFormForTable

    {

    }

    void createForm(TableId mytableId)

    {

    #AOT

    Args args;

    FormBuildDesign formBuildDesign;

    Form form;

    Formrun formrun;

    FormTabControl formTabControl;

    FormGroupControl formGroupControl;

    https://y96eha.bay.livefilestore.com/y1mQiZawWol0DZd4djzMZAWPxf8ITmvtfEPdl9f457Gg5A0zt7Lsva7258TCBqmr55zfylElX7rgVyXTdXVj1QZUU3pwlIxFnH6XSQBn0PYLQqTwdnynATAmTe4QkYPcM4h9fluXZhFjvekJMKqKS8lqg/Form%20browser-Context%20menu.jpg?psid
  • 8/10/2019 Table Browser axapta

    6/12

    FormGridControl formGridControl;

    FormBuildDataSource formBuildDataSource;

    TreeNode treeNodeForm;

    TreeNode treeNodeTable;

    TreeNode treeNodeField;

    TreeNodeIterator iterator;

    FormBuildTabControl formBuildTabControl;

    FormBuildTabPageControl formBuildTabPageControl;

    FormBuildTabPageControl formBuildTabPageControl2;

    FormBuildGridControl formBuildGridControl;

    str fieldName;

    str caption;

    str myTableName;

    int i;

    DictTable dictTable;

    ;

    dictTable = new DictTable(mytableId);

    form = new Form();

    form.name(dictTable.name());

    myTableName = tableId2Name(mytableId);

    formBuildDataSource = form.addDataSource(myTableName);

    formBuildDataSource.table(mytableId);

    formBuildDataSource.allowCreate(true);formBuildDataSource.allowDelete(true);

    formBuildDataSource.allowEdit(true);

    formBuildDesign = form.addDesign("Design");

    formBuildDesign.topMode(); // Auto

    formBuildDesign.leftMode(); // Auto

    formBuildDesign.widthMode(); // Auto

    formBuildDesign.heightMode(); // Auto

    formBuildDesign.windowType();

    formBuildDesign.caption(dictTable.name());

    formBuildDesign.titleDatasource(formbuilddatasource.id());

    // Add tabbed page controls, a grid control, and string controls.

    formBuildTabControl =

    formBuildDesign.addControl(FormControlType::Tab, "Overview");

    formBuildTabPageControl =formBuildTabControl.addControl(FormControlType::TabPage, "Overview");

  • 8/10/2019 Table Browser axapta

    7/12

    formBuildTabPageControl.caption("Overview");

    formBuildTabPageControl2 =

    formBuildTabControl.addControl(FormControlType::TabPage,"Details");

    formBuildTabPageControl2.caption("Details");

    formBuildGridControl = formBuildTabPageControl.addControl(FormControlType::GRID,

    "Grid");

    formBuildGridControl.dataSource(myTableName);

    formBuildGridControl.widthMode(1); // Column width

    formBuildGridControl.heightMode(1); // Column height

    treeNodeTable=TreeNode::findNode(#TablesPath + "\\" + myTableName + "\\Fields");

    iterator=treeNodeTable.AOTiterator();

    treeNodeField =iterator.next();

    while(treeNodeField && i

  • 8/10/2019 Table Browser axapta

    8/12

    SysContextMenu sysContextMenu;

    TreeNode treeNode;

    PSShowFormForTable psShowFormForTable;

    ;

    if (SysContextMenu::startedFrom(args))

    {

    sysContextMenu = args.parmObject();

    treeNode = sysContextMenu.first();

    tableId = SysTableBrowser::treeNode2TableId(treeNode);

    }

    if (tableId)

    {

    psShowFormForTable = new PSShowFormForTable();

    psShowFormForTable.createForm(tableId);}

    }

    Creation of ContextMenu for above class:

    Drag the above class to the action menu items, for creating the action menu item.

    AOT Menu ItemsAction

    Provide the label as Form browser andsave this action menu item.

    Place this action menu item under SysContextMenu.

    Open SysContextMenufrom AOTMenusthen drag and drop the above action menu item

    to the SysContextMenu as shown in below figure.

  • 8/10/2019 Table Browser axapta

    9/12

    We have to show this context menu item for tables only, not for all the objects in AOT.

    For this go to the following method.

    AOT ClassesSysContextMenuverifyItem

    Add the following code under the MenuItemType Actionscase

    case MenuItemType::Action:

    case menuitemactionstr(PSShowFormForTable):

    if (_firstType &&_firstType == UtilElementType::Table)

    {

    return 1;

    }

    return 0;

    Note: Here on the Form browser I am showing only 6 fields on Overviewtab and 1 field on

    Details tab.

    Depends on the requirement, we can change the number of fields in above class.

    https://y96eha.bay.livefilestore.com/y1mwQiFXeuORjJCgWtZXQyc_Yw1vPpJO3_q-AHhHOyw6E_vJ26Y92bgmYuWq1cgOyzklhVJUbEKFU8d-sfLgGyhHjq_hzihPqvvObZ5BZ6wnwsmWM6JEKoPPlo525gLLO1EfkR4_mEgv3Duagv1Nyn17A/Drag%20n%20Drop%20-%20context%20menu.jpg?psid
  • 8/10/2019 Table Browser axapta

    10/12

    Advantage: The table browser will be opened with in the Ax, whereas this form browser will

    be opened outside of Ax work space (as Ax-Forms). We can do the analysis on the table data

    in form browser very easily.

    https://y96eha.bay.livefilestore.com/y1mq3mNnefFOTCK0v1FlnoZgmXMa5kfVONT3D4mJB14WtveVh-3T86J-xX9s35UeVQdLazAGY366Bu8vOs1EVdJDOtSVQkmcVnEh5xHmu6gwblCm6AlEupyPJP-J42HPH_xXPWJt7V9p_7a674RZAoPog/SalesTable%20form%20browser.jpg?psid
  • 8/10/2019 Table Browser axapta

    11/12

    Easy Extended AX Table-Browser

    Easy Extended AX Table-Browser

    During implementations and regular developments in AX, I observed that many

    consultants/developers open the tables from AOT in the Table-Browser and by hand

    attempt to add/delete the records by hitting Ctrl+N/Alt+F9 keys and often copies the

    records from the table-browser and paste them to excel for

    checking/saving/printing/... the table data. The distress of manually copying/pasting

    of records and recalling the control-keys can be avoided by simply extending the

    Table-Browser by adding the Standard data Toolbar to the form

    Step-1: Go to the AOT and select \Forms\SysTableBrowser\Designs\Design

    and then change the design property WindowType value from Popup to Standard

    Fig1: Changing WindowType property value to Standard

    Step-2: Save and compile the SysTableBrowser Form after changing the WindowType

    property value

    Fig2: The original Table-Browser (WindowType property is Popup)

    http://3.bp.blogspot.com/_-Ku_QQcuwl8/S3gxsxMR5cI/AAAAAAAAABQ/eT0Kn5AhX48/s1600-h/Fig2-AX-TableBrowser-Original.pnghttp://1.bp.blogspot.com/_-Ku_QQcuwl8/S3gxq7ffFGI/AAAAAAAAABI/d3uJYLshcqg/s1600-h/Fig1-AX-TableBrowser-Properties.pnghttp://3.bp.blogspot.com/_-Ku_QQcuwl8/S3gxsxMR5cI/AAAAAAAAABQ/eT0Kn5AhX48/s1600-h/Fig2-AX-TableBrowser-Original.pnghttp://1.bp.blogspot.com/_-Ku_QQcuwl8/S3gxq7ffFGI/AAAAAAAAABI/d3uJYLshcqg/s1600-h/Fig1-AX-TableBrowser-Properties.png
  • 8/10/2019 Table Browser axapta

    12/12