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.

  • 相关阅读:
    痞子衡嵌入式:恩智浦i.MX RTxxx系列MCU特性那些事(1)- 概览
    痞子衡嵌入式:16MB以上NOR Flash使用不当可能会造成软复位后i.MXRT无法正常启动
    《痞子衡嵌入式半月刊》 第 12 期
    不能错过的分布式ID生成器(Leaf ),好用的一批!
    实用!一键生成数据库文档,堪称数据库界的Swagger
    安排上了!PC人脸识别登录,出乎意料的简单
    又被逼着优化代码,这次我干掉了出入参 Log日志
    图文并茂,带你认识 JVM 运行时数据区
    一文说通C#中的异步编程补遗
    一文说通C#中的异步编程
  • 原文地址:https://www.cnblogs.com/xiangliqi/p/4458983.html
Copyright © 2011-2022 走看看