Open filtered forms with X++
You usually see this used in classes such as SalesFormLetter or PurchFormLetter that uses an existing form instead of a creating a temporary one. The user enters the information and the class uses the new information to perform the tasks at hand.
This is a pretty simple job that first displays a filtered CustTable form for the customer “4004”, when this form is closed the CustTrans form will be opened and display the relevant data of the customer we are using. As this is done you will also see that it’s possible to either halt the code while a form is open or simply detach it and let the code continue.
static void OpenFilteredForms(Args _args)
{
Args argsCust, argsTrans;
FormRun formRun, formRun2;
CustTable custTable = CustTable::find("2123");
;
argsCust = new Args(formStr(CustTable));
argsCust.record(custTable);
formRun = classFactory.formRunClass(argsCust);
formRun.init();
formRun.run();
formRun.wait();
argsTrans = new Args(formStr(CustTrans));
argsTrans.record(custTable);
formRun2 = classFactory.formRunClass(argsTrans);
formRun2.init();
formRun2.run();
formRun2.detach();
print "This should be printed as " +
"the CustTrans form opens.";
pause;
}
No comments:
Post a Comment