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.

  • 相关阅读:
    Linux下面rpm命令和mount命令详解
    oracle数据库查询全系整理
    业务解决方案/-数据结构与算法速成
    SnowNLP:•中文分词•词性标准•提取文本摘要,•提取文本关键词,•转换成拼音•繁体转简体的 处理中文文本的Python3 类库
    Flask简介,安装,demo,快速入门
    人工智能,机器学习,深度学习
    机器学习 基本概念,常用经典模型
    用Python从零开始实现K近邻算法
    Sublime Text 3安装与使用,安装插件,快捷键,默认配置
    动态可视化 数据可视化之魅D3,Processing,pandas数据分析,科学计算包Numpy,可视化包Matplotlib,Matlab语言可视化的工作,Matlab没有指针和引用是个大问题
  • 原文地址:https://www.cnblogs.com/xiangliqi/p/4458983.html
Copyright © 2011-2022 走看看