Unified Operations & Dynamics AX Forum

Expand all | Collapse all

Infolog on ListPage

  • 1.  Infolog on ListPage

    SILVER CONTRIBUTOR
    Posted 18 days ago
    Edited by Richard Wu 18 days ago

    I'm trying to have an infolog pop up on the CustListPage to display the current Customer Balance.  Anyone done that before or can steer me to how I might get it done?  I've gotten the MCRCustBalancePart added to the CustTableListPage so I've got some of the information displayed which changes as I scroll through the grid, but I'd ideally like a popup only to occur when the customer balance is some value (e.g. < 0).

    This is on AX 2012 R3.

    ------------------------------
    Richard Wu
    Bicon, LLC
    Boston MA
    ------------------------------



  • 2.  RE: Infolog on ListPage

    GOLD CONTRIBUTOR
    Posted 15 days ago
    Richard,

    When do you want the infolog dialog to appear? When you are on the CustTableListPage, when you actually open up a customer record, or on some other action?

    The code to actually make it appear would be fairly straight-forward:

    CustTable ct;
    //custBalance is the current customer balance
    real custBalance;
    if(custBalance < 0){
        DialogButton db;
        str msg = strFmt("Customer with account: %1 has a balance of: %2", ct.AccountNum, custBalance);
        str title = "Customer with balance of less than zero";
        db = Box::okCancel(msg, DialogButton::Cancel, Title);
        if(db == DialogButton::Ok || db == DialogButton::Cancel)
        {
        element.close();
        }
    }

    Now you just need to decide where this code should reside. If you place it in one of the init() values of the form it will run every time that form is executed.

    ------------------------------
    Alex Meyer
    Director of Dynamics AX/365 for Finance & Operations Development
    Fastpath
    Des Moines, IA
    ------------------------------



  • 3.  RE: Infolog on ListPage

    SILVER CONTRIBUTOR
    Posted 14 days ago
    Edited by Richard Wu 13 days ago
    Hi Alex,

    I would like to have it either show up at the CustListPage grid as the records are scrolled through (active), or perhaps when a new sales order is created for that customer.  I couldn't seem to add an active method to CustListPage though.  I'll look into perhaps the sales order side though.  I tried to add it to the MCRCustBalancePart form active method, but that didn't seem to work.

    Tried adding it to the init of CustTable, but all I get is a 0.00 balance for anyone.  Doesn't seem like custBalance is getting a value; how can we get it from the customer?

    I got this to read the right value from a job, but I'm not sure how to move it to the CustTable form or the CustTableListPage.
    static void CustomerBalance(Args _args)
    {
    CustTrans custTrans;
    AccountNum accountNum = "36522";
    real custBalance;
    ;

    ttsbegin;

    while select firstonly CustTrans
    where custTrans.AccountNum == accountNum //CustTable.AccountNum == accountNum
    {
    custBalance = custTrans.mcrDisplayBalance();
    info(strFmt("Customer with account: %1 has a balance of: %2", custTrans.AccountNum, custBalance));
    }
    ttscommit;

    }

    ------------------------------
    Richard Wu
    Bicon, LLC
    Boston MA
    ------------------------------



  • 4.  RE: Infolog on ListPage

    GOLD CONTRIBUTOR
    Posted 13 days ago
    I would either recommend modifying the CustTableListPage grid to include an additional computed column of the customer balance or including this code on the init() for the CustTable form. This will execute every time an individual customer record is opened.

    public void init()
    {
      CustTrans custTrans;
      Common custRecord;
      real custBalance;

      if (element.args())
      {
        custRecord = element.args().record();
      }

      if(custRecord){
        if (custRecord.TableId == tableNum(CustTable))

       {
         int acctField = fieldNum(CustTable,AccountNum);
         str custAcctNum = custRecord.(acctField);
         while select firstonly custTrans
         where custTrans.AccountNum == custAcctNum
         {
          custBalance = custTrans.mcrDisplayBalance();
          info(strFmt("Customer with account: %1 has a balance of: %2", custTrans.AccountNum, custBalance));
        }
       }
      }

    }

    If you want this code to occur on an action from the user (creating a new sales order) then I would create an alert that would fire and execute a check.








    ------------------------------
    Alex Meyer
    Director of Dynamics AX/365 for Finance & Operations Development
    Fastpath
    Des Moines, IA
    ------------------------------



  • 5.  RE: Infolog on ListPage

    SILVER CONTRIBUTOR
    Posted 13 days ago
    That pretty much worked.  I added it to the CustTable form which already had an init() so I had to move the declarations.  I also had to specify "str 50 custAcctNum" as I  got some "container and unbound string fields are not allowed in a where clause" error when compiling.

    I think I should be able to use this to figure out getting it into the CustTableListGrid.

    Thank you very much!

    ------------------------------
    Richard Wu
    Bicon, LLC
    Boston MA
    ------------------------------



  • 6.  RE: Infolog on ListPage

    SILVER CONTRIBUTOR
    Posted 13 days ago
    Here is the modified code with the Dialog box from Alex (to force acknowledgement of the balance):


    CustTrans custTrans;
    Common custRecord;
    real custBalance;
    int acctField;
    str 50 custAcctNum;
    DialogButton db;
    str msg;
    str title;

    if (element.args())
    {
        custRecord = element.args().record();
    }

    if(custRecord){
        if (custRecord.TableId == tableNum(CustTable))
        {
            acctField = fieldNum(CustTable,AccountNum);
            custAcctNum = custRecord.(acctField);
            while select firstonly custTrans
            where custTrans.AccountNum == custAcctNum
            {
                custBalance = custTrans.mcrDisplayBalance();
                if(custBalance < 0)
                {
                    msg = strFmt("Customer with account: %1 has a balance of: %2", custTrans.AccountNum, custBalance);
                    title = "Customer with balance of less than zero";
                    db = Box::okCancel(msg, DialogButton::Cancel, Title);
                    if(db == DialogButton::Ok || db == DialogButton::Cancel)
                    {
                        element.close();
                    }
               }
            }
         }
    }

    ------------------------------
    Richard Wu
    Bicon, LLC
    Boston MA
    ------------------------------



  • 7.  RE: Infolog on ListPage

    GOLD CONTRIBUTOR
    Posted 13 days ago
    Richard,

    Thanks for debugging that code for me and posting the final result!

    Glad we were able to find a solution for you!

    ------------------------------
    Alex Meyer
    Director of Dynamics AX/365 for Finance & Operations Development
    Fastpath
    Des Moines, IA
    ------------------------------