Make Interactive property of report as No. It's easy make it as run for html with change PrintMedium enum's value.
DocuType docuType;
TextIo textIo;
FileIOPermission fioPermission;
#File
ReportRun report;
;
docuType = DocuType::find("Temp");
fileName = strfmt(@"%1My Test Report.PDF", docuType.ArchivePath);
fioPermission = new FileIOPermission(fileName ,"RW");
fioPermission.assert();
if(Global::isRunningOnServer())
{
if(WinAPIServer::fileExists(fileName))
WINAPIServer::deleteFile(fileName);
}
else
{
if(WinAPI::fileExists(fileName))
WINAPI::deleteFile(fileName);
}
report = new ReportRun(new Args(ReportStr(KRC_InventCoverReport)));
report.printJobSettings().setTarget(PrintMedium::File);
report.printJobSettings().preferredTarget(PrintMedium::File);
report.printJobSettings().format(PrintFormat::PDF);
report.printJobSettings().fileName(fileName);
report.query().interactive(false);
report.run();
26 Ocak 2016 Salı
22 Ocak 2016 Cuma
Axapta - Why sometimes MultiSelectionHelper and why sometimes traditional read?
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();
}
}
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();
}
}
Etiketler:
AX,
ax 2012,
AXAPTA,
getfirst,
getnext,
grid,
multi,
multiselect,
multiselectionhelper,
record,
select,
sort
19 Ocak 2016 Salı
Axapta - Add dimension based filter to a query
When we try to add filter based on StrFmt like this; dimension[2] = "0001" it gives error because of brackets. I found the solution from a forum page :
QueryBuildDataSource qbds = query.addDataSource(tablenum(EmplTable));
...
qbds.addRange(fieldid2Ext(fieldnum(EmplTable, Dimension),1)).value("600742");
QueryBuildDataSource qbds = query.addDataSource(tablenum(EmplTable));
...
qbds.addRange(fieldid2Ext(fieldnum(EmplTable, Dimension),1)).value("600742");
Kaydol:
Kayıtlar (Atom)