AX – D365FO – How to call Form with filtered records using code in AX 2012

Suppose you have a Form and you want to call another form passing some filters.

Go to Clicked() method of the “ViewSource” button and insert this code

void clicked()

{

   Args                 args = new Args();

   str                  menuItemDisplay = MenuItemDisplayStr(ERAInventJournalTable);

   

   MenuFunction         MenuFunction = new MenuFunction(menuItemDisplay, MenuItemType::Display);

   Query                q = new Query();

   QueryBuildDataSource qbds = q.addDataSource(tableNum(InventJournalTable));

   QBDS.addRange(fieldNum(InventJournalTable,JournalId)).value(ERAStageExtWhsInvrptbal.JournalNameId);

 

   args.initialQuery(InitialQueryParameter::createByQuery(q));

   args.caller(element);

   

   MenuFunction.run(args);

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s