Hi Professionals,
I have a menuitem in FORM A which call a class correctly.
I have another FORM B and there is a menuItem to call the same class.
I wish to call and run the same class on Form A, not Form B.
How can I hard-code form A in my class or is that possible?
class PurchTotalsSummaryController
{
}
publicstaticvoid main(Args _args)
{
PurchTotalsSummaryController my_PurchTotalsSummaryController = new PurchTotalsSummaryController();
PurchTable purchTable;
FormDataSource purchTable_ds;
purchTable = _args.record();
purchTable_ds = PurchTable.dataSource();
my_PurchTotalsSummaryController.getRecId(purchTable_ds,_args);
}
privatevoid getRecId(FormDataSource purchTable_ds, Args _args)
{
FormRun caller;
MultiSelectionHelper helper;
PurchTable purchTable;
;
//The method createFromCaller from MultiSelectionHelper has FormRun as parameter so we need to assign Args.Caller() to FormRun
caller = _args.caller();
//This method will help to get only the marked records from the Grid
helper = MultiSelectionHelper::createFromCaller(caller);
//Create the Query to filter using RecId
helper.createQueryRanges(purchTable_ds.queryBuildDataSource(), fieldStr(purchTable, RecId));
//Obtains the first query result and then assign it to table buffer
purchTable = helper.getFirst();
//True if purchLineView contains RecId
while (purchTable)
{
//Simple example to show all RecIds from selected grid rows
info(StrFmt('%1, %2, %3', purchTable.RecId,purchTable.ProjId,PurchTable.OrderAccount));
//Gets next record
purchTable = helper.getNext();
}
}