zoukankan      html  css  js  c++  java
  • Customizing AX 2012 Released Product ListPage Filter using X++

    In Microsoft Dynamics AX 2012, ListPages are more restricted from customization than in prior versions of AX.  Primary reason for the restriction is so that the list pages maintain compatibility with Enterprise Portal.  Recently a customer had a requirement where the filter needs to be available on the list page and only on the client side.  I spent quite some time searching for a solution and thought I’d share my workaround here – This post will outline how to create a customized filter on the Released Product list page.

    The Requirement: quickly find Released Product by External Item number and display the Released Product Number(s) on the Released Products List page.

    The Solution: Since we are looking for data not part of any DataSource on the original query – and due to some join complexities, customizing the existing query was also not an option, X++ became the last option. (As you may or may not know, external item data is stored in the CustVendExternalItem Table.)  Microsoft specifies for developers to change the *LPInteraction class, however I have to date not found any concrete examples for using the class to manipulate the list pages.  For this example we will modify the Released Product List Page by overriding the modified method on a filter field.

    Here is how:

    1. We need to allow overriding of methods on fields on the form (which by default is not allowed on Forms of FormTemplate: ListPage).  Navigate to the AOT –> Forms –> EcoResProductPerCompanyListPage –> Designs –> Design –> Group:Filter –>  Properties –> Display Target and select “Client”. Note this means that the filters will only be visible in the AX client and not  via EP.  This will also allow us to actually override the “modified” method on the filter form.  Ensure that the filter is Visible, DisplayTarget is set to Client and the Caption, FrameOptionButton and OptionValue can be set as needed/desired.

    EcoResProductPerCompanyListPage

    2. Create a new field under the filter section, ensure that AutoDeclaration is set to “Yes” and that the proper data type is selected.  In this case the ExtendedDataType should be “ExternalItemId”

    ExternalItem

    3.  Override the “modified” method on the Field.  Note if you are unable to override any method then you have not completed step number 1 above.

    RightClickOverrideMethod

    3. Paste code below to filter by the external customer/vend ItemId.  Note: there are many different ways to create the desired result other than below, notably the “QueryFilter” object is another alternative.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    </pre>
    public boolean modified()
    {
    boolean ret;
    QueryBuildRange qbr;
    QueryRun queryRun;
    Query query;
    QueryBuildDataSource qbds;
    SysTableLookup lookup;
    ItemId itemId;
    CustVendExternalItem custVendExternalItem;
     
    ret = super();
    if (this.valueStr())
    {
    query = new query();
    qbds = query.addDataSource(tableNum(CustVendExternalItem));
    qbr = qbds.addRange(fieldNum(CustVendExternalItem, ExternalItemId));
    qbr.value(queryValue(this.valueStr()));
    queryRun = new QueryRun(query);
    while (queryRun.next())
    {
    custVendExternalItem = queryRun.get(tableNum(custVendExternalItem));
    itemId = custVendExternalItem.ItemId;
    break;
    }
    // if we found a match in the external item table show it
    if (itemId)
    {
    InventTable_ds.queryBuildDataSource().addRange(fieldNum(InventTable, ItemId)).value(itemId);
    InventTable_ds.executeQuery();
    }
    }
    else{
    InventTable_ds.queryBuildDataSource().clearRanges();
    InventTable_ds.executeQuery();
    }
     
    return ret;
    }

    4. One nice thing about the filter Group is that it  includes a display type, I have selected “Hide” which allows a user to hide it if they do not want to see/use the specific filter with minimal screen real-estate being consumed.  Run an X++ compile on the form and Incremental CIL compile and the Released Product form should look like below.

    NewFilter1

    5.  For our example I have added a an external item Id “S1CTestItem” in the Contoso environment.  Let’s see what product this item corresponds to.  Just type in the External Item Id and hit Tab or enter.

    Filter2

    The form runs the query and displays the result.

    6.  Just to confirm, we go to the “External Item Description” form and as you can see everything checks out.

    FilterConfirmation

    That’s it!   As you can see this is the basic framework for customizing the list page form if you cannot change the Query object or are not able to pass the necessary parameters to the LPInteraction class.

  • 相关阅读:
    禁用Clusterware在系统启动后自己主动启动
    码农的产品思维培养第4节----听用户饿但不要照着做《人人都是产品经理》
    android RecycleView复杂多条目的布局
    【shell脚本练习】网卡信息和简单日志分析
    Java太阳系小游戏分析和源代码
    《你是我的眼》,歌曲非常好听
    hdu 1856 More is better(并查集)
    Python 中的isinstance函数
    Python中的 isdigit()方法
    Python中的split()函数的使用方法
  • 原文地址:https://www.cnblogs.com/xiangliqi/p/4458983.html
Copyright © 2011-2022 走看看