Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Unanswered

Multiple records printing

Posted on by 45

Hi all,

I'm quite new to the ax. The situation is like this.

I would like to print multiple official receipt . the current way is , they can only print line by line. but i would like to include all the records displayed and print it. The form is directly link to the report and the datasource is by query which i dont really know how to use it.

i managed to get the selected records in the clicked method in the form, but when it comes to the report, it loops the same records although the count of the loops is correct. So my problem is, how to make the query run into the next record?

Attach is the code.  thanks !

Form:

void clicked()
{
LedgerJournalTrans ledgerJournalTranstbl;
;

ledgerJournalTrans = ledgerJournalTrans_ds.getFirst(true);

while (ledgerJournalTrans)
{


info(strfmt(" %1 | %2 | %3", ledgerJournalTrans.AccountNum,
ledgerJournalTrans.MarkedInvoice,
ledgerJournalTrans.JournalNum));
super();
ledgerJournalTrans = ledgerJournalTrans_ds.getNext();

}

}

Report:

public void init()
{
element.initFromArgs(element.args());
info(ledgerJournalTrans.MarkedInvoice);
element.initializeQuery();
super();
monthMap = new Map(Types::String, Types::Real);
}

void initFromArgs(Args args)
{

if (args && args.dataset())
{
switch(args.dataset())
{
case tablenum(LedgerJournalTrans) :
ledgerJournalTrans = args.record();
break;

case tablenum(LedgerJournalTable) :
ledgerJournalTable = args.record();
break;

}

}
}

public void initializeQuery()
{
QueryBuildRange rangeJournalNum;
QueryBuildRange rangeVoucher;
QueryBuildRange rangeAccountType;
;

query = element.query();


if (ledgerJournalTrans)
{
rangeJournalNum = query.dataSourceTable(tablenum(LedgerJournalTrans)).findRange(fieldnum(LedgerJournalTrans,JournalNum));
rangeVoucher = query.dataSourceTable(tablenum(LedgerJournalTrans)).findRange(fieldnum(LedgerJournalTrans,Voucher));
rangeAccountType = query.dataSourceTable(tablenum(LedgerJournalTrans)).findRange(fieldnum(LedgerJournalTrans,AccountType));

if (!rangeJournalNum)
rangeJournalNum = query.dataSourceTable(tablenum(LedgerJournalTrans)).addRange(fieldnum(LedgerJournalTrans,JournalNum));

if (!rangeVoucher)
rangeVoucher = query.dataSourceTable(tablenum(LedgerJournalTrans)).addRange(fieldnum(LedgerJournalTrans,Voucher));

if (!rangeAccountType)
rangeAccountType = query.dataSourceTable(tablenum(LedgerJournalTrans)).addRange(fieldnum(LedgerJournalTrans,AccountType));

rangeJournalNum.value(QueryValue(LedgerJournalTrans.JournalNum));
rangeVoucher.value(QueryValue(LedgerJournalTrans.Voucher));
rangeAccountType.value(QueryValue(LedgerJournalACType::Cust));

}

}

boolean fetch()
{
;

queryRun = new QueryRun(this);

while (queryRun.next())
{
ledgerJournalTrans = queryRun.get(tablenum(LedgerJournalTrans));

element.buildSettleAmountList();

element.send(ledgerJournalTrans);

/*
mapEnumerator = new MapEnumerator(monthMap);

while (mapEnumerator.moveNext())
{
info(strfmt("%1 -- %2", mapEnumerator.currentKey(), mapEnumerator.currentValue()));
}
*/
}

return true;
}

Categories:

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,584 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,864 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans