• Infolog in the Dynamics AX 2009


     

    Wel all know the small dialog that gives the user usefull information about what is happening in Ax. In this post I will tell u some more about this.

    You can add information to the Infolog by calling:

    • Infolog.add(…)
    • info(…)
    • warning(…) or checkfailed(…)
    • error(…)
    • You can add some structure in it by using setPrefix(…)
    • Using the Proxy-class for the Enterprise Portal




    The info(), warning() and error() method are found in the Global class and can contain up to 3 arguments:

    • a string (mandatory) : the string that is added to the infolog
    • a path to the Axapta Help (optional)
    • an Infolog action (optional) : you can use this parameter to initiate a action, for example open the code editor or open a parameter-form when some parameters are missing. Depending on what action you want to trigger, you need to call the right method that extend from sysInfoAction.
    1234
    SysInfoAction   sysInfoAction;;sysInfoAction = SysInfoAction_Formrun::newFormname(formstr(HRMParameters));info("click on me", "", sysInfoAction);




    Using the keyword Throw before info(), error() or warning will result in terminating the execution (or jump to catch statement) and a rollback of your transactions.

    1
    throw error("Something bad happend");




    The method setPrefix() will help you to group info(), warning() and error() messages with a header. using setPrefix() will make a indentation for your current block of code (everything between { and }). Leaving the code-block will automatically result in going one indentation back.

    1234567891011121314
    int i;int j;;setPrefix("Testing out setPrefix")for (i=1 ; i<=2 ; i++){setPrefix(strfmt("Prefix %1", i))for (j=1 ; j<=3 ; j++){info(strfmt("Info %1", j));}}




    The checkFailed() method is a warning() method that returns a Boolean (alwais false). U can use this method when you want to display a warning and directly set a return value to false.

    1234567
    Boolean ret;;if (true){    ret = checkFailed("Something is wrong");}return ret;




    Note: The infolog can contain maximum 10000 lines. So try to limit the use of it. Building the output of the infolog usually happens at the end of the code you are executing and depending on the number of lines, it can take a while. You can limit the maximum number of lines under a header in a batch by setting the property infolog.errorsPerBatch(#)(). When this number is exceeded only the furst # will appear and Ax will give you a notification that their could be more errors.
    It is also possible to update the infolog while executing code by calling the method infolog.viewUpdate().


    Using the infolog in the Enterprise Portal:
    In the portal you can access the infolog by using the Proxy of the Enterprise Portal.

    12
    using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy;Proxy.Info objInfoLog = new Proxy.Info(this.AxSession.AxaptaAdapter);

    Now, when you want to write something to the infolog you need to give a Enum with it, so the portal knows if the message you want to show is a info, warning or error. So pass through Proxy.Exception.Info, Proxy.Exception.Warning or Proxy.Exception.Error.

    1
    objInfoLog.add(Proxy.Exception.Warning, "My warning");



    So in short thing you should keep in mind while using the Infolog-class:

    • Use short & informative messages
    • Choose the righty message level (info, warning, error)
    • Use actions, this simple trick is verry usefull for end-users
    • Limit the number of messages you send to the Infolog-dialog
  • 相关阅读:
    Vue源码探究-数据绑定的实现
    vue 数组遍历方法forEach和map的原理解析和实际应用
    vue 微信内H5调起支付
    uni-app官方教程学习手记
    vue-cli3 搭建的前端项目基础模板
    vue.js响应式原理解析与实现
    vue-waterfall2 基于Vue.js 瀑布流组件
    解决lucene更新删除无效的问题
    spring项目启动报错
    js监听页面copy事件添加版权信息
  • 原文地址:https://www.cnblogs.com/Fandyx/p/1920751.html
Copyright © 2020-2023  润新知