Infolog on ListPage
-
Infolog on ListPage
Posted by DSC Communities on December 28, 2018 at 11:43 am-
Richard Wu
MemberDecember 28, 2018 at 11:43 AM
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
—————————— -
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
——————————
——————————————- -
Richard Wu
MemberJanuary 2, 2019 at 6:16 AM
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
——————————
——————————————- -
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
——————————
——————————————- -
Richard Wu
MemberJanuary 2, 2019 at 10:47 AM
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
——————————
——————————————- -
Richard Wu
MemberJanuary 2, 2019 at 11:07 AM
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
——————————
——————————————- -
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
——————————
——————————————-
DSC Communities replied 6 years, 8 months ago 1 Member · 0 Replies -
-
0 Replies
Sorry, there were no replies found.
The discussion ‘Infolog on ListPage’ is closed to new replies.