That's the traditional way to read selected records from a grid:
c = CustTable_DS.getFirst(true);
while (c.RecId != 0)
{
info(c.Name);
c = CustTable_DS.getNext();
}
But there's a problem
with this way. If user just wants to process records at line instead of select a couple of records unfortunately that record will be missed. That's the workaround for this symptom:
c = CustTable_DS.getFirst(true);
noSelected = true;
while (c.RecId != 0)
{
noSelected = false;
info(c.Name);
c = CustTable_DS.getNext();
}
if (noSelected)
info(CustTable.Name);
MultiSelectionHelper solves this problem:
MultiSelectionHelper helper = MultiSelectionHelper::construct();
CustTable c;
;
helper.parmDatasource(CustTable_ds);
c = helper.getFirst();
while (c.RecId != 0)
{
info(c.Name);
c = helper.getNext();
}
But there is a disadvantage for MultiSelectionHelper class too. If user wants to sort records at grid and wants to process with this sorted list we have to use traditional way again because unfortunately MultiSelectionHelper doesn't care about users sort.
Using MultiselectionHelper from a class:
public static void main(Args _args)
{
SMAServiceOrderTable serviceOrder;
MultiSelectionHelper helper;
FormRun caller = _args.caller();
FormDataSource SMAServiceOrderTable_DS;
SMAServiceOrderTable_DS = caller.dataSource();
helper = MultiSelectionHelper::createFromCaller(caller);
helper.createQueryRanges(SMAServiceOrderTable_DS.queryBuildDataSource(),fieldStr(SMAServiceOrderTable,RecId));
serviceOrder = helper.getFirst();
while(serviceOrder)
{
info(strFmt("%1",serviceOrder.RecId));
serviceOrder = helper.getNext();
}
}
multi etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
multi etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
22 Ocak 2016 Cuma
Axapta - Why sometimes MultiSelectionHelper and why sometimes traditional read?
Etiketler:
AX,
ax 2012,
AXAPTA,
getfirst,
getnext,
grid,
multi,
multiselect,
multiselectionhelper,
record,
select,
sort
11 Temmuz 2014 Cuma
AX 2012 - Send marked records to SSRS RDP Report
SSRS DP Class don't accept table or container data types as parm method. I searched at forums and saw str data type adviced. But I think this's not best approach. At last learned best way already in standard AX SSRS reports. At this link there's a PDF file tells look for check report. I generated this report with look form ChequeDP and ChequeController classes:
Controller class:
class declaration:
class myController extends SrsReportRunController
{
#define.ReportName('myreport.Report')
myTMPTable myTMPTable;
}
public static void main(Args _args)
{
SysLastValue SysLastValue;
myController controller = new myController();
controller.parmReportName(#ReportName);
controller.parmArgs(_args);
controller.DeleteTmpData();
controller.init();
controller.startOperation();
}
protected void prePromptModifyContract()
{
SrsTmpTblMarshallerContract contract = this.parmReportContract().parmRdpContract() as SrsTmpTblMarshallerContract;
new SRSReportRunPermission().assert();
contract.parmTmpTableDataRecId(SRSTmpTblMarshaller::SendTmpTblToDataProvider(myTMPTable));
}
public void init()
{
FormDataSource ds;
TransDate transDate;
VendTrans vendTrans;
if (!this.parmArgs() ||
!this.parmArgs().record() ||
this.parmArgs().dataset() != tableNum(VendTrans))
throw error("Report should be call with correct parameter!..");
ds = this.parmArgs().record().dataSource();
vendTrans = ds.getFirst(1);
transDate = vendTrans.transDate;
PaymentReceipt.VendAccount = vendTrans.AccountNum;
for (vendTrans = ds.getFirst(1); vendTrans != null; vendTrans = ds.getNext())
{
myTMPTable.Date = vendTrans.TransDate;
...
myTMPTable.insert();
}
}
DP Class:
// <ETG - memre > GN: T: 11.07.2014 A:
[SRSReportParameterAttribute(classStr(SrsTmpTblMarshallerContract))]
public class mpDP extends SRSReportDataProviderBase
{
myTMPTAble myTMPTable;
}
private void initTmpTable()
{
SrsTmpTblMarshallerContract contract = this.parmDataContract() as SrsTmpTblMarshallerContract;
new SRSReportRunPermission().assert();
myTMPTable = SRSTmpTblMarshaller::getTmpTbl(contract.parmTmpTableDataRecId());
SRSTmpTblMarshaller::deleteTmpTblData(contract.parmTmpTableDataRecId());
CodeAccessPermission::revertAssert();
}
public void processReport()
{
CompanyInfo Company;
VendTable vendTable;
AmountMST amount;
TempStr NumtoTxt;
LedgerJournalTrans LedgerTrans;
this.initTmpTable();
...
}
Controller class:
class declaration:
class myController extends SrsReportRunController
{
#define.ReportName('myreport.Report')
myTMPTable myTMPTable;
}
public static void main(Args _args)
{
SysLastValue SysLastValue;
myController controller = new myController();
controller.parmReportName(#ReportName);
controller.parmArgs(_args);
controller.DeleteTmpData();
controller.init();
controller.startOperation();
}
protected void prePromptModifyContract()
{
SrsTmpTblMarshallerContract contract = this.parmReportContract().parmRdpContract() as SrsTmpTblMarshallerContract;
new SRSReportRunPermission().assert();
contract.parmTmpTableDataRecId(SRSTmpTblMarshaller::SendTmpTblToDataProvider(myTMPTable));
}
public void init()
{
FormDataSource ds;
TransDate transDate;
VendTrans vendTrans;
if (!this.parmArgs() ||
!this.parmArgs().record() ||
this.parmArgs().dataset() != tableNum(VendTrans))
throw error("Report should be call with correct parameter!..");
ds = this.parmArgs().record().dataSource();
vendTrans = ds.getFirst(1);
transDate = vendTrans.transDate;
PaymentReceipt.VendAccount = vendTrans.AccountNum;
for (vendTrans = ds.getFirst(1); vendTrans != null; vendTrans = ds.getNext())
{
myTMPTable.Date = vendTrans.TransDate;
...
myTMPTable.insert();
}
}
DP Class:
// <ETG - memre > GN: T: 11.07.2014 A:
[SRSReportParameterAttribute(classStr(SrsTmpTblMarshallerContract))]
public class mpDP extends SRSReportDataProviderBase
{
myTMPTAble myTMPTable;
}
private void initTmpTable()
{
SrsTmpTblMarshallerContract contract = this.parmDataContract() as SrsTmpTblMarshallerContract;
new SRSReportRunPermission().assert();
myTMPTable = SRSTmpTblMarshaller::getTmpTbl(contract.parmTmpTableDataRecId());
SRSTmpTblMarshaller::deleteTmpTblData(contract.parmTmpTableDataRecId());
CodeAccessPermission::revertAssert();
}
public void processReport()
{
CompanyInfo Company;
VendTable vendTable;
AmountMST amount;
TempStr NumtoTxt;
LedgerJournalTrans LedgerTrans;
this.initTmpTable();
...
}
Kaydol:
Kayıtlar (Atom)