Skip to main content

Pass Query from dialog to Form and Filter records

Created a Runbase class which has dialog selection using QueryStr.
I need to pass this Query range selection to a form and need to filter records based on this query Selection. Call the form by passing the Query selection from the class

Args _args;
FormRun _formRun;
EmplId _empId;
;
_args = new Args(); // creating a object for args class
_args.name(formstr(xtgCummeInquiry)); // Form Menuitem
_args.caller(this); // Form Caller(Current Form is mentioned as this)
_args.object(CummeQueryRun.query());
_formRun = ClassFactory.formRunClass(_args);
//new FormRun(_args);
// Creating object for FormRun
_formRun.init(); // Form Initialization for Load
_formRun.run(); // Form Run for process
_formRun.wait(); // Form Wait for Display
and from the called form run method,assign the Query range value to the form datasource
public void run()
{
boolean ret;
Query q;
DictField dictField;
str fieldLabel;
Addressing PrintRange;
int i, j, rangeCount;
QueryBuildRange QBR;
QueryRun Qrun;
super();
if(element.args().caller())
{
CallerOBJ = element.args().caller();
Qrun = CallerObj.QueryRun();
q = QRun.query();
for(i = 1; i <= q.dataSourceCount(); i++)
{
rangeCount = q.dataSourceNo(i).rangeCount();
for(j = 1; j <= rangeCount; j++)
{
QBR = q.dataSourceNo(i).range(j);
dictField = new DictField(QBR.table(),fieldname2id(QBR.table(),QBR.name()));
fieldLabel = dictField.label();
if(QBR.value())
{
CummeTransTable_q.dataSourceTable(QBR.table()).addRange(fieldname2id(QBR.table(),QBR.name())).value(QBR.value());
}
}
}
}
CummeTransTable_ds.executeQuery();
}

Popular posts from this blog

Dynamics Axapta: Sales Orders & Business Connector

Well, again folllowing my same idea of writting close to nothing and pasting code, I'll paste in some code to create a sales order from some basic data and the invoice it. I'll try to explain more in the future. AxaptaObject axSalesTable = ax.CreateAxaptaObject("AxSalesTable"); AxaptaRecord rcInventDim = ax.CreateAxaptaRecord("InventDim"); AxaptaRecord rcCustTable = ax.CreateAxaptaRecord("CustTable"); rcCustTable.ExecuteStmt("select * from %1 where %1.AccountNum == '" + MySalesOrderObject.CustAccount + "'"); if (MySalesOrderObject.CurrencyCode.Trim().Length == 0) MySalesOrderObject.CurrencyCode = rcCustTable.get_Field("Currency").ToString().Trim(); string sTaxGroup = rcCustTable.get_Field("taxgroup").ToString().Trim(); //set header level fields axSalesTable.Call("parmSalesName", MySalesOrderObject.SalesName.Trim()); axSalesTable.Call("parmCustAccount", M

Passing values between form and class

Class name is EmplDuplication and Form is EmplTable . void clicked() {    MenuFunction mf;    args args = new Args();    ;     args.record(EmplTable);     mf = new menufunction(identifierstr(EmplDuplication), MenuItemType::Action); mf.run(args); } Meanwhile, in the main() method of the EmplDuplication class, we need to put this Axapta x++ code to get the datasource: static void main(Args args) {     EmplDuplication EmplDuplication; EmplTable localEmplTable; ;     if(args.record().TableId == tablenum(EmplTable)) localEmplTable = args.record();     ... }